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

+18
View File
@@ -159,6 +159,24 @@ class AxisNetworkDevice:
"""Stop the event stream."""
self.api.stop()
async def async_reset(self):
"""Reset this device to default state."""
self.api.stop()
if self.config_entry.options[CONF_CAMERA]:
await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, 'camera')
if self.config_entry.options[CONF_EVENTS]:
await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, 'binary_sensor')
for unsub_dispatcher in self.listeners:
unsub_dispatcher()
self.listeners = []
return True
async def get_device(hass, config):
"""Create a Axis device."""