From 115df52f6749f63cf1bb1c7863acae8541351e9e Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Tue, 31 Jan 2023 22:19:43 +0100 Subject: [PATCH] Issue#36 - Error at initialisation Issue#32 - Error with Fan Modes on thermostat over climate type --- .../versatile_thermostat/climate.py | 18 +++++++++++++----- .../versatile_thermostat/strings.json | 12 ++++++++++++ .../versatile_thermostat/translations/en.json | 12 ++++++++++++ .../versatile_thermostat/translations/fr.json | 12 ++++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/custom_components/versatile_thermostat/climate.py b/custom_components/versatile_thermostat/climate.py index 453d1bf..b5448ef 100644 --- a/custom_components/versatile_thermostat/climate.py +++ b/custom_components/versatile_thermostat/climate.py @@ -220,6 +220,8 @@ class VersatileThermostat(ClimateEntity, RestoreEntity): self._is_over_climate = False self._underlying_climate = None + self._attr_translation_key = "versatile_thermostat" + self.post_init(entry_infos) def post_init(self, entry_infos): @@ -864,11 +866,14 @@ class VersatileThermostat(ClimateEntity, RestoreEntity): @property def _is_device_active(self): """If the toggleable device is currently active.""" - if self._is_over_climate and self._underlying_climate: - return self._underlying_climate.hvac_action not in [ - CURRENT_HVAC_IDLE, - CURRENT_HVAC_OFF, - ] + if self._is_over_climate: + if self._underlying_climate: + return self._underlying_climate.hvac_action not in [ + CURRENT_HVAC_IDLE, + CURRENT_HVAC_OFF, + ] + else: + return None else: return self.hass.states.is_state(self._heater_entity_id, STATE_ON) @@ -881,6 +886,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity): """Set new target hvac mode.""" _LOGGER.info("%s - Set hvac mode: %s", self, hvac_mode) + if hvac_mode is None: + return + if self._is_over_climate and self._underlying_climate: data = {ATTR_ENTITY_ID: self._climate_entity_id, "hvac_mode": hvac_mode} await self.hass.services.async_call( diff --git a/custom_components/versatile_thermostat/strings.json b/custom_components/versatile_thermostat/strings.json index 1014654..1f58d80 100644 --- a/custom_components/versatile_thermostat/strings.json +++ b/custom_components/versatile_thermostat/strings.json @@ -209,5 +209,17 @@ "thermostat_over_climate": "Thermostat over another thermostat" } } + }, + "entity": { + "climate": { + "versatile_thermostat": { + "states_attributes": { + "preset_mode": { + "power": "Shedding", + "security": "Security" + } + } + } + } } } \ No newline at end of file diff --git a/custom_components/versatile_thermostat/translations/en.json b/custom_components/versatile_thermostat/translations/en.json index 1014654..1f58d80 100644 --- a/custom_components/versatile_thermostat/translations/en.json +++ b/custom_components/versatile_thermostat/translations/en.json @@ -209,5 +209,17 @@ "thermostat_over_climate": "Thermostat over another thermostat" } } + }, + "entity": { + "climate": { + "versatile_thermostat": { + "states_attributes": { + "preset_mode": { + "power": "Shedding", + "security": "Security" + } + } + } + } } } \ No newline at end of file diff --git a/custom_components/versatile_thermostat/translations/fr.json b/custom_components/versatile_thermostat/translations/fr.json index dfb0e91..c3fdbd7 100644 --- a/custom_components/versatile_thermostat/translations/fr.json +++ b/custom_components/versatile_thermostat/translations/fr.json @@ -209,5 +209,17 @@ "thermostat_over_climate": "Thermostat sur un autre thermostat" } } + }, + "entity": { + "climate": { + "versatile_thermostat": { + "states_attributes": { + "preset_mode": { + "power": "Délestage", + "security": "Sécurité" + } + } + } + } } } \ No newline at end of file