Axis component support unloading entries (#22692)

* Add support for unloading entries

* Improve config entry tests

* Improve coverage for device

* Remove callback when relevant
This commit is contained in:
Robert Svensson authored and Paulus Schoutsen committed 2019-04-15 15:06:45 -07:00
1 parent dbcdc32f05
commit 60c787c2e6
10 files changed
+192 -70

No files matched your search

@@ -42,6 +42,11 @@ class AxisBinarySensor(BinarySensorDevice):
self.unsub_dispatcher = async_dispatcher_connect(
self.hass, self.device.event_reachable, self.update_callback)
async def async_will_remove_from_hass(self) -> None:
"""Disconnect device object when removed."""
self.event.remove_callback(self.update_callback)
self.unsub_dispatcher()
@callback
def update_callback(self, no_delay=False):
"""Update the sensor's state, if needed.