diff --git a/custom_components/yandex_station/climate.py b/custom_components/yandex_station/climate.py index ea085b5..1b006ee 100644 --- a/custom_components/yandex_station/climate.py +++ b/custom_components/yandex_station/climate.py @@ -130,16 +130,26 @@ def internal_update(self, capabilities: dict, properties: dict): async def async_added_to_hass(self): if item := self.config.get("current_temperature"): - on_remove = utils.track_template(self.hass, item, self.on_track_template) + on_remove = utils.track_template(self.hass, item, self.on_track_temperature) + self.async_on_remove(on_remove) + if item := self.config.get("current_humidity"): + on_remove = utils.track_template(self.hass, item, self.on_track_humidity) self.async_on_remove(on_remove) - def on_track_template(self, value): + def on_track_temperature(self, value): try: self._attr_current_temperature = float(value) except: self._attr_current_temperature = None self._async_write_ha_state() + def on_track_humidity(self, value): + try: + self._attr_current_humidity = int(value) + except: + self._attr_current_humidity = None + self._async_write_ha_state() + async def async_set_hvac_mode(self, hvac_mode: HVACMode): if hvac_mode == HVACMode.OFF: kwargs = {"on": False}