Unsub dispatcher when removing entity from hass (#33510)

* Unsub dispatcher when removing entity from hass

* Update homeassistant/components/plaato/sensor.py

Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/volvooncall/__init__.py

Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Paulus SchoutsenandMartin Hjelmare authored and GitHub committed 2020-04-02 09:25:33 -07:00
1 parent 314bc07cee
commit 4ebbabcdd1
71 files changed
+355 -209

No files matched your search

+4 -8
View File
@@ -61,7 +61,6 @@ class ArloCam(Camera):
self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS)
self._last_refresh = None
self.attrs = {}
self._unsub_disp = None
def camera_image(self):
"""Return a still image response from the camera."""
@@ -69,15 +68,12 @@ class ArloCam(Camera):
async def async_added_to_hass(self):
"""Register callbacks."""
self._unsub_disp = async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ARLO, self.async_write_ha_state
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ARLO, self.async_write_ha_state
)
)
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
self._unsub_disp()
self._unsub_disp = None
async def handle_async_mjpeg_stream(self, request):
"""Generate an HTTP MJPEG stream from the camera."""
video = await self.hass.async_add_executor_job(