From 8cd96ade7d067e878d60cf7fc163730c6271fa8f Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:36:13 +0200 Subject: [PATCH] Revert "Merge pull request #123 from basbruss/async_event" This reverts commit a5eb5efdb58b55628da5c8f74261391b45241937, reversing changes made to 335cd1b043756869cf273f448504a8c69c2d3c70. --- custom_components/adaptive_cover/__init__.py | 6 +++--- custom_components/adaptive_cover/coordinator.py | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/adaptive_cover/__init__.py b/custom_components/adaptive_cover/__init__.py index 8c6a21f..ab1b6c2 100644 --- a/custom_components/adaptive_cover/__init__.py +++ b/custom_components/adaptive_cover/__init__.py @@ -6,7 +6,7 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.event import ( - async_track_state_change_event, + async_track_state_change, ) from .const import ( @@ -48,7 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: _entities.append(entity) entry.async_on_unload( - async_track_state_change_event( + async_track_state_change( hass, _entities, coordinator.async_check_entity_state_change, @@ -56,7 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) entry.async_on_unload( - async_track_state_change_event( + async_track_state_change( hass, _cover_entities, coordinator.async_check_cover_state_change, diff --git a/custom_components/adaptive_cover/coordinator.py b/custom_components/adaptive_cover/coordinator.py index ce10284..4d71955 100644 --- a/custom_components/adaptive_cover/coordinator.py +++ b/custom_components/adaptive_cover/coordinator.py @@ -13,7 +13,7 @@ SERVICE_SET_COVER_POSITION, SERVICE_SET_COVER_TILT_POSITION, ) -from homeassistant.core import Event, EventStateChangedData, HomeAssistant, State +from homeassistant.core import HomeAssistant, State from homeassistant.helpers.template import state_attr from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -120,21 +120,20 @@ async def async_config_entry_first_refresh(self) -> None: await super().async_config_entry_first_refresh() _LOGGER.debug("Config entry first refresh") - async def async_check_entity_state_change(self) -> None: + async def async_check_entity_state_change( + self, entity: str, old_state: State | None, new_state: State | None + ) -> None: """Fetch and process state change event.""" _LOGGER.debug("Entity state change") self.state_change = True await self.async_refresh() async def async_check_cover_state_change( - self, event: Event[EventStateChangedData] + self, entity: str, old_state: State | None, new_state: State | None ) -> None: """Fetch and process state change event.""" _LOGGER.debug("Cover state change") - data = event.data - self.state_change_data = StateChangedData( - data["entity_id"], data["old_state"], data["new_state"] - ) + self.state_change_data = StateChangedData(entity, old_state, new_state) self.cover_state_change = True self.process_entity_state_change() await self.async_refresh()