Adjust callback registration in harmony (#77533)
parent
5f31bdf2d7
commit
b47de426d8
|
@ -105,16 +105,18 @@ class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity):
|
||||||
if ATTR_ACTIVITY in data:
|
if ATTR_ACTIVITY in data:
|
||||||
self.default_activity = data[ATTR_ACTIVITY]
|
self.default_activity = data[ATTR_ACTIVITY]
|
||||||
|
|
||||||
def _setup_callbacks(self):
|
def _setup_callbacks(self) -> None:
|
||||||
callbacks = {
|
self.async_on_remove(
|
||||||
"connected": self.async_got_connected,
|
self._data.async_subscribe(
|
||||||
"disconnected": self.async_got_disconnected,
|
HarmonyCallback(
|
||||||
"config_updated": self.async_new_config,
|
connected=self.async_got_connected,
|
||||||
"activity_starting": self.async_new_activity,
|
disconnected=self.async_got_disconnected,
|
||||||
"activity_started": self.async_new_activity_finished,
|
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)))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_new_activity_finished(self, activity_info: tuple) -> None:
|
def async_new_activity_finished(self, activity_info: tuple) -> None:
|
||||||
|
|
|
@ -58,18 +58,19 @@ class HarmonyActivitySwitch(HarmonyEntity, SwitchEntity):
|
||||||
"""Stop this activity."""
|
"""Stop this activity."""
|
||||||
await self._data.async_power_off()
|
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."""
|
"""Call when entity is added to hass."""
|
||||||
|
self.async_on_remove(
|
||||||
callbacks = {
|
self._data.async_subscribe(
|
||||||
"connected": self.async_got_connected,
|
HarmonyCallback(
|
||||||
"disconnected": self.async_got_disconnected,
|
connected=self.async_got_connected,
|
||||||
"activity_starting": self._async_activity_update,
|
disconnected=self.async_got_disconnected,
|
||||||
"activity_started": self._async_activity_update,
|
activity_starting=self._async_activity_update,
|
||||||
"config_updated": None,
|
activity_started=self._async_activity_update,
|
||||||
}
|
config_updated=None,
|
||||||
|
)
|
||||||
self.async_on_remove(self._data.async_subscribe(HarmonyCallback(**callbacks)))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_activity_update(self, activity_info: tuple):
|
def _async_activity_update(self, activity_info: tuple):
|
||||||
|
|
Loading…
Reference in New Issue