From c47fb5d161b1ede68158de80c4ade102bdeaa22e Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Wed, 17 Jan 2024 15:55:46 +0100 Subject: [PATCH] Remove deprecated redundant dry and fan modes from `zwave_js` climates (#108124) Remove deprecated redundant dry and fan modes from zwave_js climates --- homeassistant/components/zwave_js/climate.py | 29 +----- .../components/zwave_js/strings.json | 11 --- tests/components/zwave_js/test_climate.py | 98 ------------------- 3 files changed, 1 insertion(+), 137 deletions(-) diff --git a/homeassistant/components/zwave_js/climate.py b/homeassistant/components/zwave_js/climate.py index d511a030fb1a21..2506db13f6daed 100644 --- a/homeassistant/components/zwave_js/climate.py +++ b/homeassistant/components/zwave_js/climate.py @@ -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 @@ -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 @@ -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) diff --git a/homeassistant/components/zwave_js/strings.json b/homeassistant/components/zwave_js/strings.json index 19a47450080ffa..ee6a7c3d0b738c 100644 --- a/homeassistant/components/zwave_js/strings.json +++ b/homeassistant/components/zwave_js/strings.json @@ -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": { diff --git a/tests/components/zwave_js/test_climate.py b/tests/components/zwave_js/test_climate.py index e4550b7f961fe9..b2e7c3139166ad 100644 --- a/tests/components/zwave_js/test_climate.py +++ b/tests/components/zwave_js/test_climate.py @@ -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, @@ -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, @@ -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 - )