diff --git a/homeassistant/components/alarm_control_panel/simplisafe.py b/homeassistant/components/alarm_control_panel/simplisafe.py index cdcdf07c982cee..9bb9922f0e39b5 100644 --- a/homeassistant/components/alarm_control_panel/simplisafe.py +++ b/homeassistant/components/alarm_control_panel/simplisafe.py @@ -96,6 +96,8 @@ def update(): async def async_will_remove_from_hass(self) -> None: """Disconnect dispatcher listener when removed.""" + await super.async_will_remove_from_hass() + if self._async_unsub_dispatcher_connect: self._async_unsub_dispatcher_connect() diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index a1f1563f5e1850..80db7e301fb05a 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -291,6 +291,8 @@ async def async_trigger(self, variables, skip_condition=False, async def async_will_remove_from_hass(self): """Remove listeners when removing automation from HASS.""" + await super.async_will_remove_from_hass() + await self.async_turn_off() async def async_enable(self): diff --git a/homeassistant/components/binary_sensor/deconz.py b/homeassistant/components/binary_sensor/deconz.py index b0728ad167c580..43042513c049a9 100644 --- a/homeassistant/components/binary_sensor/deconz.py +++ b/homeassistant/components/binary_sensor/deconz.py @@ -56,6 +56,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect sensor object when removed.""" + await super.async_will_remove_from_hass() + self._sensor.remove_callback(self.async_update_callback) self._sensor = None diff --git a/homeassistant/components/binary_sensor/openuv.py b/homeassistant/components/binary_sensor/openuv.py index 3e9bb0b0bc3f54..2fad865040988a 100644 --- a/homeassistant/components/binary_sensor/openuv.py +++ b/homeassistant/components/binary_sensor/openuv.py @@ -92,6 +92,8 @@ def update(): async def async_will_remove_from_hass(self): """Disconnect dispatcher listener when removed.""" + await super.async_will_remove_from_hass() + if self._async_unsub_dispatcher_connect: self._async_unsub_dispatcher_connect() diff --git a/homeassistant/components/cover/deconz.py b/homeassistant/components/cover/deconz.py index 89b29aa10a5573..f437044c689d49 100644 --- a/homeassistant/components/cover/deconz.py +++ b/homeassistant/components/cover/deconz.py @@ -66,6 +66,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect cover object when removed.""" + await super.async_will_remove_from_hass() + self._cover.remove_callback(self.async_update_callback) self._cover = None diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index 4dd3571e69c2a6..06d0aae5e7def4 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -507,6 +507,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self): """Handle removal from HASS.""" + await super.async_will_remove_from_hass() + if self._async_unsub_state_changed: self._async_unsub_state_changed() self._async_unsub_state_changed = None diff --git a/homeassistant/components/light/deconz.py b/homeassistant/components/light/deconz.py index d3bec079a4c958..04c75d4ef1555a 100644 --- a/homeassistant/components/light/deconz.py +++ b/homeassistant/components/light/deconz.py @@ -85,6 +85,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect light object when removed.""" + await super.async_will_remove_from_hass() + self._light.remove_callback(self.async_update_callback) self._light = None diff --git a/homeassistant/components/light/group.py b/homeassistant/components/light/group.py index bf54d3ecf29586..a44dab50e6752e 100644 --- a/homeassistant/components/light/group.py +++ b/homeassistant/components/light/group.py @@ -82,6 +82,8 @@ def async_state_changed_listener(entity_id: str, old_state: State, async def async_will_remove_from_hass(self): """Handle removal from HASS.""" + await super.async_will_remove_from_hass() + if self._async_unsub_state_changed is not None: self._async_unsub_state_changed() self._async_unsub_state_changed = None diff --git a/homeassistant/components/media_player/cast.py b/homeassistant/components/media_player/cast.py index d6515b9476d32b..4399a80af4c5b2 100644 --- a/homeassistant/components/media_player/cast.py +++ b/homeassistant/components/media_player/cast.py @@ -356,6 +356,8 @@ async def async_stop(event): async def async_will_remove_from_hass(self) -> None: """Disconnect Chromecast object when removed.""" + await super.async_will_remove_from_hass() + await self._async_disconnect() if self._cast_info.uuid is not None: # Remove the entity from the added casts so that it can dynamically diff --git a/homeassistant/components/scene/deconz.py b/homeassistant/components/scene/deconz.py index b8fca6d863074c..49cabfc23bed5d 100644 --- a/homeassistant/components/scene/deconz.py +++ b/homeassistant/components/scene/deconz.py @@ -47,6 +47,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect scene object when removed.""" + await super.async_will_remove_from_hass() + self._scene = None async def async_activate(self): diff --git a/homeassistant/components/script.py b/homeassistant/components/script.py index 16c9f65420c3c6..77952696813b3f 100644 --- a/homeassistant/components/script.py +++ b/homeassistant/components/script.py @@ -179,6 +179,8 @@ async def async_turn_off(self, **kwargs): async def async_will_remove_from_hass(self): """Stop script and remove service when it will be removed from HASS.""" + await super.async_will_remove_from_hass() + if self.script.is_running: self.script.async_stop() diff --git a/homeassistant/components/sensor/deconz.py b/homeassistant/components/sensor/deconz.py index c66bda2bc1d809..4dd510dc096c0e 100644 --- a/homeassistant/components/sensor/deconz.py +++ b/homeassistant/components/sensor/deconz.py @@ -66,6 +66,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect sensor object when removed.""" + await super.async_will_remove_from_hass() + self._sensor.remove_callback(self.async_update_callback) self._sensor = None @@ -170,6 +172,8 @@ def __init__(self, sensor): async def async_added_to_hass(self): """Subscribe to sensors events.""" + await super.async_will_remove_from_hass() + self._sensor.register_async_callback(self.async_update_callback) self.hass.data[DATA_DECONZ_ID][self.entity_id] = self._sensor.deconz_id diff --git a/homeassistant/components/switch/deconz.py b/homeassistant/components/switch/deconz.py index f8911d65d987d9..86a6fb28d02260 100644 --- a/homeassistant/components/switch/deconz.py +++ b/homeassistant/components/switch/deconz.py @@ -57,6 +57,8 @@ async def async_added_to_hass(self): async def async_will_remove_from_hass(self) -> None: """Disconnect switch object when removed.""" + await super.async_will_remove_from_hass() + self._switch.remove_callback(self.async_update_callback) self._switch = None