Fix handling with register callbacks on added_to_hass (#7067)

This commit is contained in:
Pascal Vizeli 2017-04-12 09:51:19 +02:00 committed by GitHub
parent f06cff35ff
commit e026717239
2 changed files with 5 additions and 3 deletions

View file

@ -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()

View file

@ -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):