Revert partial changes to deCONZ integration from earlier PR (#41943)

This commit is contained in:
Robert Svensson 2020-10-16 14:38:12 +02:00 committed by GitHub
parent 23b3db08f3
commit 85ccff28cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 9 deletions

View File

@ -81,8 +81,7 @@ class DeconzDevice(DeconzBase, Entity):
async def async_will_remove_from_hass(self) -> None: async def async_will_remove_from_hass(self) -> None:
"""Disconnect device object when removed.""" """Disconnect device object when removed."""
self._device.remove_callback(self.async_update_callback) self._device.remove_callback(self.async_update_callback)
if self.entity_id in self.gateway.deconz_ids: del self.gateway.deconz_ids[self.entity_id]
del self.gateway.deconz_ids[self.entity_id]
self.gateway.entities[self.TYPE].remove(self.unique_id) self.gateway.entities[self.TYPE].remove(self.unique_id)
@callback @callback

View File

@ -34,7 +34,7 @@ from .errors import AuthenticationRequired, CannotConnect
@callback @callback
def get_gateway_from_config_entry(hass, config_entry): def get_gateway_from_config_entry(hass, config_entry):
"""Return gateway with a matching bridge id.""" """Return gateway with a matching bridge id."""
return hass.data[DOMAIN].get(config_entry.unique_id) return hass.data[DOMAIN][config_entry.unique_id]
class DeconzGateway: class DeconzGateway:
@ -192,9 +192,6 @@ class DeconzGateway:
""" """
gateway = get_gateway_from_config_entry(hass, entry) gateway = get_gateway_from_config_entry(hass, entry)
if not gateway:
return
if gateway.api.host != gateway.host: if gateway.api.host != gateway.host:
gateway.api.close() gateway.api.close()
gateway.api.host = gateway.host gateway.api.host = gateway.host

View File

@ -113,9 +113,8 @@ async def test_gateway_setup_fails(hass):
with patch( with patch(
"homeassistant.components.deconz.gateway.get_gateway", side_effect=Exception "homeassistant.components.deconz.gateway.get_gateway", side_effect=Exception
): ):
config_entry = await setup_deconz_integration(hass) await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry) assert not hass.data[deconz.DOMAIN]
assert gateway is None
async def test_connection_status_signalling(hass): async def test_connection_status_signalling(hass):