Switch harmony to async_on_remove (#34378)

This commit is contained in:
J. Nick Koston 2020-04-18 13:36:15 -05:00 committed by GitHub
parent 71c8fcee20
commit b78b705e32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,7 +166,6 @@ class HarmonyRemote(remote.RemoteDevice):
self.delay_secs = delay_secs
self._available = False
self._unique_id = unique_id
self._undo_dispatch_subscription = None
@property
def activity_names(self):
@ -181,11 +180,6 @@ class HarmonyRemote(remote.RemoteDevice):
return activities
async def async_will_remove_from_hass(self):
"""Undo subscription."""
if self._undo_dispatch_subscription:
self._undo_dispatch_subscription()
async def _async_update_options(self, data):
"""Change options when the options flow does."""
if ATTR_DELAY_SECS in data:
@ -205,10 +199,12 @@ class HarmonyRemote(remote.RemoteDevice):
disconnect=self.got_disconnected,
)
self._undo_dispatch_subscription = async_dispatcher_connect(
self.hass,
f"{HARMONY_OPTIONS_UPDATE}-{self.unique_id}",
self._async_update_options,
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{HARMONY_OPTIONS_UPDATE}-{self.unique_id}",
self._async_update_options,
)
)
# Store Harmony HUB config, this will also update our current