Create zwave_js repair issue instead of warning log entry (#95997)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
0dc5875cbd
commit
f2726527f2
3 changed files with 51 additions and 10 deletions
|
@ -37,6 +37,7 @@ from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemper
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN, LOGGER
|
from .const import DATA_CLIENT, DOMAIN, LOGGER
|
||||||
|
@ -502,13 +503,27 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||||
preset_mode_value = self._hvac_presets.get(preset_mode)
|
preset_mode_value = self._hvac_presets.get(preset_mode)
|
||||||
if preset_mode_value is None:
|
if preset_mode_value is None:
|
||||||
raise ValueError(f"Received an invalid preset mode: {preset_mode}")
|
raise ValueError(f"Received an invalid preset mode: {preset_mode}")
|
||||||
# Dry and Fan preset modes are deprecated as of 2023.8
|
# Dry and Fan preset modes are deprecated as of Home Assistant 2023.8.
|
||||||
# Use Dry and Fan HVAC modes instead
|
# Please use Dry and Fan HVAC modes instead.
|
||||||
if preset_mode_value in (ThermostatMode.DRY, ThermostatMode.FAN):
|
if preset_mode_value in (ThermostatMode.DRY, ThermostatMode.FAN):
|
||||||
LOGGER.warning(
|
LOGGER.warning(
|
||||||
"Dry and Fan preset modes are deprecated and will be removed in a future release. "
|
"Dry and Fan preset modes are deprecated and will be removed in Home Assistant 2024.2. "
|
||||||
"Use the corresponding Dry and Fan HVAC modes instead"
|
"Please use the corresponding Dry and Fan HVAC modes instead"
|
||||||
)
|
)
|
||||||
|
async_create_issue(
|
||||||
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
f"dry_fan_presets_deprecation_{self.entity_id}",
|
||||||
|
breaks_in_ha_version="2024.2.0",
|
||||||
|
is_fixable=True,
|
||||||
|
is_persistent=True,
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
translation_key="dry_fan_presets_deprecation",
|
||||||
|
translation_placeholders={
|
||||||
|
"entity_id": self.entity_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
await self._async_set_value(self._current_mode, preset_mode_value)
|
await self._async_set_value(self._current_mode, preset_mode_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,17 @@
|
||||||
"invalid_server_version": {
|
"invalid_server_version": {
|
||||||
"title": "Newer version of Z-Wave JS Server needed",
|
"title": "Newer version of Z-Wave JS Server needed",
|
||||||
"description": "The version of Z-Wave JS Server you are currently running is too old for this version of Home Assistant. Please update the Z-Wave JS Server to the latest version to fix this issue."
|
"description": "The version of Z-Wave JS Server you are currently running is too old for this version of Home Assistant. Please update the Z-Wave JS Server to the latest version to fix this issue."
|
||||||
|
},
|
||||||
|
"dry_fan_presets_deprecation": {
|
||||||
|
"title": "Dry and Fan preset modes will be removed: {entity_id}",
|
||||||
|
"fix_flow": {
|
||||||
|
"step": {
|
||||||
|
"confirm": {
|
||||||
|
"title": "Dry and Fan preset modes will be removed: {entity_id}",
|
||||||
|
"description": "You are using the Dry or Fan preset modes in your entity `{entity_id}`.\n\nDry and Fan preset modes are deprecated and will be removed. Please update your automations to use the corresponding Dry and Fan **HVAC modes** instead.\n\nClick on SUBMIT below once you have manually fixed this issue."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services": {
|
"services": {
|
||||||
|
|
|
@ -40,6 +40,7 @@ from homeassistant.const import (
|
||||||
ATTR_TEMPERATURE,
|
ATTR_TEMPERATURE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import issue_registry as ir
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
CLIMATE_AIDOO_HVAC_UNIT_ENTITY,
|
CLIMATE_AIDOO_HVAC_UNIT_ENTITY,
|
||||||
|
@ -722,14 +723,14 @@ async def test_thermostat_dry_and_fan_both_hvac_mode_and_preset(
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def test_thermostat_warning_when_setting_dry_preset(
|
async def test_thermostat_raise_repair_issue_and_warning_when_setting_dry_preset(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
client,
|
client,
|
||||||
climate_airzone_aidoo_control_hvac_unit,
|
climate_airzone_aidoo_control_hvac_unit,
|
||||||
integration,
|
integration,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test warning when setting Dry preset."""
|
"""Test raise of repair issue and warning when setting Dry preset."""
|
||||||
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
|
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
|
||||||
assert state
|
assert state
|
||||||
|
|
||||||
|
@ -743,20 +744,27 @@ async def test_thermostat_warning_when_setting_dry_preset(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
issue_id = f"dry_fan_presets_deprecation_{CLIMATE_AIDOO_HVAC_UNIT_ENTITY}"
|
||||||
|
issue_registry = ir.async_get(hass)
|
||||||
|
|
||||||
|
assert issue_registry.async_get_issue(
|
||||||
|
domain=DOMAIN,
|
||||||
|
issue_id=issue_id,
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
"Dry and Fan preset modes are deprecated and will be removed in a future release. Use the corresponding Dry and Fan HVAC modes instead"
|
"Dry and Fan preset modes are deprecated and will be removed in Home Assistant 2024.2. Please use the corresponding Dry and Fan HVAC modes instead"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_thermostat_warning_when_setting_fan_preset(
|
async def test_thermostat_raise_repair_issue_and_warning_when_setting_fan_preset(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
client,
|
client,
|
||||||
climate_airzone_aidoo_control_hvac_unit,
|
climate_airzone_aidoo_control_hvac_unit,
|
||||||
integration,
|
integration,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test warning when setting Fan preset."""
|
"""Test raise of repair issue and warning when setting Fan preset."""
|
||||||
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
|
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
|
||||||
assert state
|
assert state
|
||||||
|
|
||||||
|
@ -770,7 +778,14 @@ async def test_thermostat_warning_when_setting_fan_preset(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
issue_id = f"dry_fan_presets_deprecation_{CLIMATE_AIDOO_HVAC_UNIT_ENTITY}"
|
||||||
|
issue_registry = ir.async_get(hass)
|
||||||
|
|
||||||
|
assert issue_registry.async_get_issue(
|
||||||
|
domain=DOMAIN,
|
||||||
|
issue_id=issue_id,
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
"Dry and Fan preset modes are deprecated and will be removed in a future release. Use the corresponding Dry and Fan HVAC modes instead"
|
"Dry and Fan preset modes are deprecated and will be removed in Home Assistant 2024.2. Please use the corresponding Dry and Fan HVAC modes instead"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue