From 8369eff04a333bba57e751af978f6cc5b0eb6a46 Mon Sep 17 00:00:00 2001 From: nielsfaber Date: Sat, 16 Nov 2024 08:33:53 +0100 Subject: [PATCH] replace deprecated function async_track_state_change by async_track_state_change_event --- custom_components/zoned_heating/const.py | 2 +- custom_components/zoned_heating/switch.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/custom_components/zoned_heating/const.py b/custom_components/zoned_heating/const.py index 0e03cc7..2712d97 100755 --- a/custom_components/zoned_heating/const.py +++ b/custom_components/zoned_heating/const.py @@ -1,6 +1,6 @@ """Store constants.""" -VERSION = "1.1.1" +VERSION = "1.1.2" DOMAIN = "zoned_heating" NAME = "Zoned Heating" DATA = "data" diff --git a/custom_components/zoned_heating/switch.py b/custom_components/zoned_heating/switch.py index 55bae9b..9a2afc5 100755 --- a/custom_components/zoned_heating/switch.py +++ b/custom_components/zoned_heating/switch.py @@ -17,7 +17,7 @@ from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.event import ( - async_track_state_change, + async_track_state_change_event, async_track_point_in_time, ) from homeassistant.components.climate.const import ( @@ -143,12 +143,12 @@ async def async_start_state_listeners(self): if not len(self._zone_entities) or not self._controller_entity: return self._state_listeners = [ - async_track_state_change( + async_track_state_change_event( self.hass, self._controller_entity, self.async_controller_state_changed, ), - async_track_state_change( + async_track_state_change_event( self.hass, self._zone_entities, self.async_zone_state_changed, @@ -161,12 +161,12 @@ async def async_stop_state_listeners(self): self._state_listeners.pop()() @callback - async def async_controller_state_changed(self, entity, old_state, new_state): + async def async_controller_state_changed(self, event): """fired when controller entity changes""" if self._ignore_controller_state_change_timer or not self._override_active: return - old_state = parse_state(old_state) - new_state = parse_state(new_state) + old_state = parse_state(event.data["old_state"]) + new_state = parse_state(event.data["new_state"]) if new_state[ATTR_TEMPERATURE] != old_state[ATTR_TEMPERATURE]: # if controller setpoint has changed, make sure to store it @@ -179,10 +179,11 @@ async def async_controller_state_changed(self, entity, old_state, new_state): await self.async_turn_off_zones() @callback - async def async_zone_state_changed(self, entity, old_state, new_state): + async def async_zone_state_changed(self, event): """fired when zone entity changes""" - old_state = parse_state(old_state) - new_state = parse_state(new_state) + entity = event.data["entity_id"] + old_state = parse_state(event.data["old_state"]) + new_state = parse_state(event.data["new_state"]) if ( old_state[ATTR_TEMPERATURE] != new_state[ATTR_TEMPERATURE] and