Adjust callback registration in harmony (#77533)
parent
5f31bdf2d7
commit
b47de426d8
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue