From 7ddc9bbefdc64bdfdb2ea0e225815cc70dc78268 Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Fri, 15 Mar 2024 14:42:41 +0000 Subject: [PATCH 1/3] Fix deprecates uses of TEMP_CELSIUS --- custom_components/wundasmart/climate.py | 4 ++-- custom_components/wundasmart/water_heater.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/wundasmart/climate.py b/custom_components/wundasmart/climate.py index 198107e..665fbbf 100644 --- a/custom_components/wundasmart/climate.py +++ b/custom_components/wundasmart/climate.py @@ -19,7 +19,7 @@ CONF_HOST, CONF_USERNAME, CONF_PASSWORD, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -89,7 +89,7 @@ class Device(CoordinatorEntity[WundasmartDataUpdateCoordinator], ClimateEntity): """Representation of an Wundasmart climate.""" _attr_hvac_modes = SUPPORTED_HVAC_MODES - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_preset_modes = SUPPORTED_PRESET_MODES _attr_translation_key = DOMAIN diff --git a/custom_components/wundasmart/water_heater.py b/custom_components/wundasmart/water_heater.py index ca4a51a..231eef3 100644 --- a/custom_components/wundasmart/water_heater.py +++ b/custom_components/wundasmart/water_heater.py @@ -15,7 +15,7 @@ CONF_HOST, CONF_USERNAME, CONF_PASSWORD, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import aiohttp_client, entity_platform @@ -124,7 +124,7 @@ class Device(CoordinatorEntity[WundasmartDataUpdateCoordinator], WaterHeaterEnti _attr_operation_list = list(sorted({ OPERATION_SET_AUTO } | HW_BOOST_OPERATIONS | HW_OFF_OPERATIONS, key=_split_operation)) _attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_translation_key = DOMAIN def __init__( From f8b7bb52ea4d2c82e173ba777c52fd6789e733a9 Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Fri, 15 Mar 2024 15:38:41 +0000 Subject: [PATCH 2/3] Fix warning about ClimateEntityFeature usage This adds ClimateEntityFeature.TURN_ON and ClimateEntityFeature.TURN_OFF to supported features and disables the backwards compatibility flag related to those. This prevents a warning at initialization. Specific warning is: Entity None () implements HVACMode(s): off, auto, heat and therefore implicitly supports the turn_on/turn_off methods without setting the proper ClimateEntityFeature. Please create a bug report at https://github.com/tonyroberts/hawundasmart/issues --- custom_components/wundasmart/climate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/wundasmart/climate.py b/custom_components/wundasmart/climate.py index 665fbbf..b400041 100644 --- a/custom_components/wundasmart/climate.py +++ b/custom_components/wundasmart/climate.py @@ -113,8 +113,15 @@ def __init__( self._attr_unique_id = device["id"] self._attr_type = device["device_type"] self._attr_device_info = coordinator.device_info + # This flag needs to be set until 2025.1 to prevent warnings about + # implicitly supporting the turn_off/turn_on methods. + # https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded/ + self._enable_turn_on_off_backwards_compatibility = False self._attr_supported_features = ( - ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE + ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.PRESET_MODE + | ClimateEntityFeature.TURN_OFF + | ClimateEntityFeature.TURN_ON ) self._attr_current_temperature = None self._attr_target_temperature = None From 29402597fb92050d10963d717d45f2ac9ed44846 Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Sun, 17 Mar 2024 14:31:08 +0000 Subject: [PATCH 3/3] Remove TURN_OFF and TURN_ON flags --- custom_components/wundasmart/climate.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/custom_components/wundasmart/climate.py b/custom_components/wundasmart/climate.py index b400041..80fd483 100644 --- a/custom_components/wundasmart/climate.py +++ b/custom_components/wundasmart/climate.py @@ -118,10 +118,7 @@ def __init__( # https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded/ self._enable_turn_on_off_backwards_compatibility = False self._attr_supported_features = ( - ClimateEntityFeature.TARGET_TEMPERATURE - | ClimateEntityFeature.PRESET_MODE - | ClimateEntityFeature.TURN_OFF - | ClimateEntityFeature.TURN_ON + ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) self._attr_current_temperature = None self._attr_target_temperature = None