deCONZ - move event handling (#40424)

* Working draft

* Remove event references in sensor
This commit is contained in:
Robert Svensson 2020-09-22 19:55:10 +02:00 committed by GitHub
parent 6e8e4eedb5
commit fb7fb0ea78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 17 deletions

View file

@ -25,6 +25,7 @@ from .const import (
NEW_SENSOR,
SUPPORTED_PLATFORMS,
)
from .deconz_event import async_setup_events, async_unload_events
from .errors import AuthenticationRequired, CannotConnect
@ -112,6 +113,8 @@ class DeconzGateway:
)
)
self.hass.async_create_task(async_setup_events(self))
self.api.start()
self.config_entry.add_update_listener(self.async_config_entry_updated)
@ -227,9 +230,7 @@ class DeconzGateway:
unsub_dispatcher()
self.listeners = []
for event in self.events:
event.async_will_remove_from_hass()
self.events.clear()
await async_unload_events(self)
self.deconz_ids = {}
return True