From b47de426d8e281402089398054dc335b1b6e2ab8 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 30 Aug 2022 15:54:32 +0200 Subject: [PATCH] Adjust callback registration in harmony (#77533) --- homeassistant/components/harmony/remote.py | 22 +++++++++++---------- homeassistant/components/harmony/switch.py | 23 +++++++++++----------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/harmony/remote.py b/homeassistant/components/harmony/remote.py index 93d72f0ef7e..5dfd6d6290d 100644 --- a/homeassistant/components/harmony/remote.py +++ b/homeassistant/components/harmony/remote.py @@ -105,16 +105,18 @@ class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity): if ATTR_ACTIVITY in data: self.default_activity = data[ATTR_ACTIVITY] - def _setup_callbacks(self): - callbacks = { - "connected": self.async_got_connected, - "disconnected": self.async_got_disconnected, - "config_updated": self.async_new_config, - "activity_starting": self.async_new_activity, - "activity_started": self.async_new_activity_finished, - } - - self.async_on_remove(self._data.async_subscribe(HarmonyCallback(**callbacks))) + def _setup_callbacks(self) -> None: + self.async_on_remove( + self._data.async_subscribe( + HarmonyCallback( + connected=self.async_got_connected, + disconnected=self.async_got_disconnected, + config_updated=self.async_new_config, + activity_starting=self.async_new_activity, + activity_started=self.async_new_activity_finished, + ) + ) + ) @callback def async_new_activity_finished(self, activity_info: tuple) -> None: diff --git a/homeassistant/components/harmony/switch.py b/homeassistant/components/harmony/switch.py index 200c261b565..fe2238293da 100644 --- a/homeassistant/components/harmony/switch.py +++ b/homeassistant/components/harmony/switch.py @@ -58,18 +58,19 @@ class HarmonyActivitySwitch(HarmonyEntity, SwitchEntity): """Stop this activity.""" await self._data.async_power_off() - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Call when entity is added to hass.""" - - callbacks = { - "connected": self.async_got_connected, - "disconnected": self.async_got_disconnected, - "activity_starting": self._async_activity_update, - "activity_started": self._async_activity_update, - "config_updated": None, - } - - self.async_on_remove(self._data.async_subscribe(HarmonyCallback(**callbacks))) + self.async_on_remove( + self._data.async_subscribe( + HarmonyCallback( + connected=self.async_got_connected, + disconnected=self.async_got_disconnected, + activity_starting=self._async_activity_update, + activity_started=self._async_activity_update, + config_updated=None, + ) + ) + ) @callback def _async_activity_update(self, activity_info: tuple):