From c9c3a8fe38f66465818194857ae26a8772123568 Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Mon, 7 Dec 2020 05:10:46 -0800 Subject: [PATCH] Unregister updates when a Wemo entry is removed (#44005) --- homeassistant/components/wemo/binary_sensor.py | 5 +++++ homeassistant/components/wemo/fan.py | 5 +++++ homeassistant/components/wemo/light.py | 5 +++++ homeassistant/components/wemo/switch.py | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/homeassistant/components/wemo/binary_sensor.py b/homeassistant/components/wemo/binary_sensor.py index b5ef3dc528b..44031e846c3 100644 --- a/homeassistant/components/wemo/binary_sensor.py +++ b/homeassistant/components/wemo/binary_sensor.py @@ -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. diff --git a/homeassistant/components/wemo/fan.py b/homeassistant/components/wemo/fan.py index 1bc477277c9..c7325f776fa 100644 --- a/homeassistant/components/wemo/fan.py +++ b/homeassistant/components/wemo/fan.py @@ -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. diff --git a/homeassistant/components/wemo/light.py b/homeassistant/components/wemo/light.py index 6aac2be6dda..5d4aa18ee2b 100644 --- a/homeassistant/components/wemo/light.py +++ b/homeassistant/components/wemo/light.py @@ -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. diff --git a/homeassistant/components/wemo/switch.py b/homeassistant/components/wemo/switch.py index fc00d4ea8b5..e2210d0279a 100644 --- a/homeassistant/components/wemo/switch.py +++ b/homeassistant/components/wemo/switch.py @@ -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.