Skip to content

Commit

Permalink
Always call super in will)remove_from_hass
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Oct 25, 2018
1 parent fdfb7c2 commit 689da70
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/alarm_control_panel/simplisafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/binary_sensor/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/binary_sensor/openuv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/cover/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/group/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/light/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/light/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/media_player/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/scene/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/sensor/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/switch/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 689da70

Please sign in to comment.