Add deCONZ service to clean up orphaned device and entity entries (#40629)

* Add service that can clean up by deCONZ orphaned entries from device and entity registry

* Fix existing tests

* Add new test

* Add some inline comment to the service
This commit is contained in:
Robert Svensson 2020-09-30 20:11:41 +02:00 committed by GitHub
parent 9bdc716e60
commit 9d56d3bb31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 169 additions and 6 deletions

View file

@ -51,6 +51,7 @@ class DeconzGateway:
self.ignore_state_updates = False
self.deconz_ids = {}
self.device_id = None
self.entities = {}
self.events = []
self.listeners = []
@ -139,7 +140,7 @@ class DeconzGateway:
async def async_update_device_registry(self) -> None:
"""Update device registry."""
device_registry = await self.hass.helpers.device_registry.async_get_registry()
device_registry.async_get_or_create(
entry = device_registry.async_get_or_create(
config_entry_id=self.config_entry.entry_id,
connections={(CONNECTION_NETWORK_MAC, self.api.config.mac)},
identifiers={(DOMAIN, self.api.config.bridgeid)},
@ -148,6 +149,7 @@ class DeconzGateway:
name=self.api.config.name,
sw_version=self.api.config.swversion,
)
self.device_id = entry.id
async def async_setup(self) -> bool:
"""Set up a deCONZ gateway."""