Fix deconz tests that have uncaught exceptions (#33462)
This commit is contained in:
1 parent
977f1a6916
commit
f2f03cf552
3 files changed
+7
-9
No files matched your search
@@ -86,9 +86,10 @@ class DeconzDevice(DeconzBase, Entity):
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Disconnect device object when removed."""
|
||||
self._device.remove_callback(self.async_update_callback)
|
||||
del self.gateway.deconz_ids[self.entity_id]
|
||||
for unsub_dispatcher in self.listeners:
|
||||
unsub_dispatcher()
|
||||
if self.entity_id in self.gateway.deconz_ids:
|
||||
del self.gateway.deconz_ids[self.entity_id]
|
||||
for unsub_dispatcher in self.listeners:
|
||||
unsub_dispatcher()
|
||||
|
||||
async def async_remove_self(self, deconz_ids: list) -> None:
|
||||
"""Schedule removal of this entity.
|
||||
|
||||
@@ -31,7 +31,7 @@ from .errors import AuthenticationRequired, CannotConnect
|
||||
@callback
|
||||
def get_gateway_from_config_entry(hass, config_entry):
|
||||
"""Return gateway with a matching bridge id."""
|
||||
return hass.data[DOMAIN][config_entry.unique_id]
|
||||
return hass.data[DOMAIN].get(config_entry.unique_id)
|
||||
|
||||
|
||||
class DeconzGateway:
|
||||
@@ -126,6 +126,8 @@ class DeconzGateway:
|
||||
Causes for this is either discovery updating host address or config entry options changing.
|
||||
"""
|
||||
gateway = get_gateway_from_config_entry(hass, entry)
|
||||
if not gateway:
|
||||
return
|
||||
if gateway.api.host != entry.data[CONF_HOST]:
|
||||
gateway.api.close()
|
||||
gateway.api.host = entry.data[CONF_HOST]
|
||||
|
||||
Reference in new issue
Block a user