Unregister updates when a Wemo entry is removed (#44005)

This commit is contained in:
Eric Severance 2020-12-07 05:10:46 -08:00 committed by GitHub
parent 6ce45e39d1
commit c9c3a8fe38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View File

@ -67,6 +67,11 @@ class WemoBinarySensor(BinarySensorEntity):
await self.hass.async_add_executor_job(registry.register, self.wemo)
registry.on(self.wemo, None, self._subscription_callback)
async def async_will_remove_from_hass(self) -> None:
"""Wemo sensor removed from hass."""
registry = self.hass.data[WEMO_DOMAIN]["registry"]
await self.hass.async_add_executor_job(registry.unregister, self.wemo)
async def async_update(self):
"""Update WeMo state.

View File

@ -249,6 +249,11 @@ class WemoHumidifier(FanEntity):
await self.hass.async_add_executor_job(registry.register, self.wemo)
registry.on(self.wemo, None, self._subscription_callback)
async def async_will_remove_from_hass(self) -> None:
"""Wemo humidifier removed from hass."""
registry = self.hass.data[WEMO_DOMAIN]["registry"]
await self.hass.async_add_executor_job(registry.unregister, self.wemo)
async def async_update(self):
"""Update WeMo state.

View File

@ -279,6 +279,11 @@ class WemoDimmer(LightEntity):
await self.hass.async_add_executor_job(registry.register, self.wemo)
registry.on(self.wemo, None, self._subscription_callback)
async def async_will_remove_from_hass(self) -> None:
"""Wemo dimmer removed from hass."""
registry = self.hass.data[WEMO_DOMAIN]["registry"]
await self.hass.async_add_executor_job(registry.unregister, self.wemo)
async def async_update(self):
"""Update WeMo state.

View File

@ -220,6 +220,11 @@ class WemoSwitch(SwitchEntity):
await self.hass.async_add_executor_job(registry.register, self.wemo)
registry.on(self.wemo, None, self._subscription_callback)
async def async_will_remove_from_hass(self) -> None:
"""Wemo switch removed from hass."""
registry = self.hass.data[WEMO_DOMAIN]["registry"]
await self.hass.async_add_executor_job(registry.unregister, self.wemo)
async def async_update(self):
"""Update WeMo state.