mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fix sonos async use (#17099)
* Entry setup wasn't using the async api. Fix this by using correct async api.s * Also use new async executor scheduler in async_added_to_hass.
This commit is contained in:
parent
abd329d707
commit
6a0c9a718e
@ -133,9 +133,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
"""Sync version of async add devices."""
|
"""Sync version of async add devices."""
|
||||||
hass.add_job(async_add_entities, devices, update_before_add)
|
hass.add_job(async_add_entities, devices, update_before_add)
|
||||||
|
|
||||||
hass.add_job(_setup_platform, hass,
|
hass.async_add_executor_job(
|
||||||
hass.data[SONOS_DOMAIN].get('media_player', {}),
|
_setup_platform, hass, hass.data[SONOS_DOMAIN].get('media_player', {}),
|
||||||
add_entities, None)
|
add_entities, None)
|
||||||
|
|
||||||
|
|
||||||
def _setup_platform(hass, config, add_entities, discovery_info):
|
def _setup_platform(hass, config, add_entities, discovery_info):
|
||||||
@ -366,7 +366,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Subscribe sonos events."""
|
"""Subscribe sonos events."""
|
||||||
self.hass.data[DATA_SONOS].devices.append(self)
|
self.hass.data[DATA_SONOS].devices.append(self)
|
||||||
self.hass.async_add_job(self._subscribe_to_player_events)
|
self.hass.async_add_executor_job(self._subscribe_to_player_events)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user