Skip to content

Commit

Permalink
Add current_humidity template to climate #513
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Oct 13, 2024
1 parent 58d5c37 commit 57fb32c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions custom_components/yandex_station/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 57fb32c

Please sign in to comment.