Refactor august to use self.async_on_remove (#42333)
This commit is contained in:
parent
6822190772
commit
3f18cdc75e
2 changed files with 17 additions and 14 deletions
|
@ -46,18 +46,13 @@ class AugustEntityMixin(Entity):
|
|||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to updates."""
|
||||
self._data.async_subscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
self.async_on_remove(
|
||||
self._data.async_subscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
)
|
||||
)
|
||||
self._data.activity_stream.async_subscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""Undo subscription."""
|
||||
self._data.async_unsubscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
)
|
||||
self._data.activity_stream.async_unsubscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
self.async_on_remove(
|
||||
self._data.activity_stream.async_subscribe_device_id(
|
||||
self._device_id, self._update_from_data_and_write_state
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue