Skip to content

Commit

Permalink
replace deprecated function async_track_state_change by async_track_s…
Browse files Browse the repository at this point in the history
…tate_change_event
  • Loading branch information
nielsfaber committed Nov 16, 2024
1 parent 3f2a1c3 commit 8369eff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/zoned_heating/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Store constants."""

VERSION = "1.1.1"
VERSION = "1.1.2"
DOMAIN = "zoned_heating"
NAME = "Zoned Heating"
DATA = "data"
Expand Down
19 changes: 10 additions & 9 deletions custom_components/zoned_heating/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8369eff

Please sign in to comment.