From e3815885f2842a5471e334c57c36aa411d443e9e Mon Sep 17 00:00:00 2001 From: JulienLD Date: Fri, 17 Feb 2023 22:58:57 -0500 Subject: [PATCH 1/2] resolve dvd-dev/hilo#219 --- custom_components/hilo/climate.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/custom_components/hilo/climate.py b/custom_components/hilo/climate.py index 6d98e84..0052d4e 100644 --- a/custom_components/hilo/climate.py +++ b/custom_components/hilo/climate.py @@ -2,9 +2,9 @@ from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate.const import ( - HVAC_MODE_HEAT, - HVAC_MODE_OFF, - SUPPORT_TARGET_TEMPERATURE, + ClimateEntityFeature, + HVACAction, + HVACMode, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, TEMP_CELSIUS @@ -49,15 +49,16 @@ async def async_setup_entry( class HiloClimate(HiloEntity, ClimateEntity): - _attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_OFF] + _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF] + _attr_hvac_actions = [HVACAction.HEATING, HVACAction.IDLE] _attr_temperature_unit: str = TEMP_CELSIUS _attr_precision: float = PRECISION_TENTHS - _attr_supported_features: int = SUPPORT_TARGET_TEMPERATURE + _attr_supported_features: int = ClimateEntityFeature.TARGET_TEMPERATURE def __init__(self, hilo: Hilo, device): super().__init__(hilo, device=device, name=device.name) self._attr_unique_id = f"{slugify(device.name)}-climate" - self.operations = [HVAC_MODE_HEAT, HVAC_MODE_OFF] + self.operations = [HVACMode.HEAT, HVACMode.OFF] self._has_operation = False self._temperature_entity = None LOG.debug(f"Setting up Climate entity: {self._attr_name}") @@ -79,16 +80,19 @@ def min_temp(self): return self._device.min_temp def set_hvac_mode(self, hvac_mode): - """Set operation mode.""" return @property def hvac_mode(self): return self._device.hvac_mode + @property + def hvac_action(self): + return self._device.hvac_action + @property def icon(self): - if self._device.hvac_mode == HVAC_MODE_HEAT: + if self._device.hvac_action == HVACAction.HEATING: return "mdi:radiator" return "mdi:radiator-disabled" From 5c47f3129dfcebbd428edfb1b34ba3b49828323f Mon Sep 17 00:00:00 2001 From: JulienLD Date: Fri, 17 Feb 2023 23:46:46 -0500 Subject: [PATCH 2/2] enlever le code mort --- custom_components/hilo/climate.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/hilo/climate.py b/custom_components/hilo/climate.py index 0052d4e..4322e3a 100644 --- a/custom_components/hilo/climate.py +++ b/custom_components/hilo/climate.py @@ -49,8 +49,7 @@ async def async_setup_entry( class HiloClimate(HiloEntity, ClimateEntity): - _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF] - _attr_hvac_actions = [HVACAction.HEATING, HVACAction.IDLE] + _attr_hvac_modes = [HVACMode.HEAT] _attr_temperature_unit: str = TEMP_CELSIUS _attr_precision: float = PRECISION_TENTHS _attr_supported_features: int = ClimateEntityFeature.TARGET_TEMPERATURE @@ -58,7 +57,7 @@ class HiloClimate(HiloEntity, ClimateEntity): def __init__(self, hilo: Hilo, device): super().__init__(hilo, device=device, name=device.name) self._attr_unique_id = f"{slugify(device.name)}-climate" - self.operations = [HVACMode.HEAT, HVACMode.OFF] + self.operations = [HVACMode.HEAT] self._has_operation = False self._temperature_entity = None LOG.debug(f"Setting up Climate entity: {self._attr_name}") @@ -84,7 +83,7 @@ def set_hvac_mode(self, hvac_mode): @property def hvac_mode(self): - return self._device.hvac_mode + return HVACMode.HEAT @property def hvac_action(self):