Skip to content

Commit

Permalink
Remove deprecated redundant dry and fan modes from zwave_js climates (
Browse files Browse the repository at this point in the history
home-assistant#108124)

Remove deprecated redundant dry and fan modes from zwave_js climates
  • Loading branch information
jbouwh authored Jan 17, 2024
1 parent 91815ed commit c47fb5d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 137 deletions.
29 changes: 1 addition & 28 deletions homeassistant/components/zwave_js/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
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 .const import DATA_CLIENT, DOMAIN, LOGGER
from .const import DATA_CLIENT, DOMAIN
from .discovery import ZwaveDiscoveryInfo
from .discovery_data_template import DynamicCurrentTempClimateDataTemplate
from .entity import ZWaveBaseEntity
Expand Down Expand Up @@ -243,11 +242,6 @@ def _set_modes_and_presets(self) -> None:
# treat value as hvac mode
if hass_mode := ZW_HVAC_MODE_MAP.get(mode_id):
all_modes[hass_mode] = mode_id
# Dry and Fan modes are in the process of being migrated from
# presets to hvac modes. In the meantime, we will set them as
# both, presets and hvac modes, to maintain backwards compatibility
if mode_id in (ThermostatMode.DRY, ThermostatMode.FAN):
all_presets[mode_name] = mode_id
else:
# treat value as hvac preset
all_presets[mode_name] = mode_id
Expand Down Expand Up @@ -503,27 +497,6 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:
preset_mode_value = self._hvac_presets.get(preset_mode)
if preset_mode_value is None:
raise ValueError(f"Received an invalid preset mode: {preset_mode}")
# Dry and Fan preset modes are deprecated as of Home Assistant 2023.8.
# Please use Dry and Fan HVAC modes instead.
if preset_mode_value in (ThermostatMode.DRY, ThermostatMode.FAN):
LOGGER.warning(
"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"
)
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)

Expand Down
11 changes: 0 additions & 11 deletions homeassistant/components/zwave_js/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,6 @@
"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."
},
"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."
}
}
}
},
"device_config_file_changed": {
"title": "Device configuration file changed: {device_name}",
"fix_flow": {
Expand Down
98 changes: 0 additions & 98 deletions tests/components/zwave_js/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
ATTR_MAX_TEMP,
ATTR_MIN_TEMP,
ATTR_PRESET_MODE,
ATTR_PRESET_MODES,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
DOMAIN as CLIMATE_DOMAIN,
Expand All @@ -41,10 +40,8 @@
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers import issue_registry as ir

from .common import (
CLIMATE_AIDOO_HVAC_UNIT_ENTITY,
CLIMATE_DANFOSS_LC13_ENTITY,
CLIMATE_EUROTRONICS_SPIRIT_Z_ENTITY,
CLIMATE_FLOOR_THERMOSTAT_ENTITY,
Expand Down Expand Up @@ -769,98 +766,3 @@ async def test_thermostat_unknown_values(
state = hass.states.get(CLIMATE_RADIO_THERMOSTAT_ENTITY)

assert ATTR_HVAC_ACTION not in state.attributes


async def test_thermostat_dry_and_fan_both_hvac_mode_and_preset(
hass: HomeAssistant,
client,
climate_airzone_aidoo_control_hvac_unit,
integration,
) -> None:
"""Test that dry and fan modes are both available as hvac mode and preset."""
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
assert state
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.HEAT,
HVACMode.COOL,
HVACMode.FAN_ONLY,
HVACMode.DRY,
HVACMode.HEAT_COOL,
]
assert state.attributes[ATTR_PRESET_MODES] == [
PRESET_NONE,
"Fan",
"Dry",
]


async def test_thermostat_raise_repair_issue_and_warning_when_setting_dry_preset(
hass: HomeAssistant,
client,
climate_airzone_aidoo_control_hvac_unit,
integration,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test raise of repair issue and warning when setting Dry preset."""
client.async_send_command.return_value = {"result": {"status": 1}}

state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
assert state

await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{
ATTR_ENTITY_ID: CLIMATE_AIDOO_HVAC_UNIT_ENTITY,
ATTR_PRESET_MODE: "Dry",
},
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 (
"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
)


async def test_thermostat_raise_repair_issue_and_warning_when_setting_fan_preset(
hass: HomeAssistant,
client,
climate_airzone_aidoo_control_hvac_unit,
integration,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test raise of repair issue and warning when setting Fan preset."""
client.async_send_command.return_value = {"result": {"status": 1}}
state = hass.states.get(CLIMATE_AIDOO_HVAC_UNIT_ENTITY)
assert state

await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{
ATTR_ENTITY_ID: CLIMATE_AIDOO_HVAC_UNIT_ENTITY,
ATTR_PRESET_MODE: "Fan",
},
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 (
"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
)

0 comments on commit c47fb5d

Please sign in to comment.