From 57fb32cb1944a5a666c4aca26abce533194668d1 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sun, 13 Oct 2024 14:19:20 +0300 Subject: [PATCH] Add current_humidity template to climate #513 --- custom_components/yandex_station/climate.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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}