From e026717239f1e7653fed6029c3dc7d967ef2c855 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Wed, 12 Apr 2017 09:51:19 +0200 Subject: [PATCH] Fix handling with register callbacks on added_to_hass (#7067) --- homeassistant/components/lutron_caseta.py | 6 ++++-- homeassistant/components/media_player/sonos.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/lutron_caseta.py b/homeassistant/components/lutron_caseta.py index 416c9f7fd00..5519240bc49 100644 --- a/homeassistant/components/lutron_caseta.py +++ b/homeassistant/components/lutron_caseta.py @@ -77,8 +77,10 @@ class LutronCasetaDevice(Entity): @asyncio.coroutine def async_added_to_hass(self): """Register callbacks.""" - self._smartbridge.add_subscriber(self._device_id, - self._update_callback) + self.hass.async_add_job( + self._smartbridge.add_subscriber, self._device_id, + self._update_callback + ) def _update_callback(self): self.schedule_update_ha_state() diff --git a/homeassistant/components/media_player/sonos.py b/homeassistant/components/media_player/sonos.py index cd837948b46..00cc52ab3a1 100644 --- a/homeassistant/components/media_player/sonos.py +++ b/homeassistant/components/media_player/sonos.py @@ -292,7 +292,7 @@ class SonosDevice(MediaPlayerDevice): @asyncio.coroutine def async_added_to_hass(self): """Subscribe sonos events.""" - self.hass.loop.run_in_executor(None, self._subscribe_to_player_events) + self.hass.async_add_job(self._subscribe_to_player_events) @property def should_poll(self):