Fix race during initial Sonos group construction (#26371)
* Fix race during initial Sonos group construction * Update homeassistant/components/sonos/media_player.py
This commit is contained in:
parent
a74bb3fd5e
commit
a980eedd22
1 changed files with 8 additions and 4 deletions
|
@ -337,8 +337,16 @@ class SonosEntity(MediaPlayerDevice):
|
|||
async def async_added_to_hass(self):
|
||||
"""Subscribe sonos events."""
|
||||
await self.async_seen()
|
||||
|
||||
self.hass.data[DATA_SONOS].entities.append(self)
|
||||
|
||||
def _rebuild_groups():
|
||||
"""Build the current group topology."""
|
||||
for entity in self.hass.data[DATA_SONOS].entities:
|
||||
entity.update_groups()
|
||||
|
||||
self.hass.async_add_executor_job(_rebuild_groups)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique ID."""
|
||||
|
@ -469,10 +477,6 @@ class SonosEntity(MediaPlayerDevice):
|
|||
self.update_volume()
|
||||
self._set_favorites()
|
||||
|
||||
# New player available, build the current group topology
|
||||
for entity in self.hass.data[DATA_SONOS].entities:
|
||||
entity.update_groups()
|
||||
|
||||
player = self.soco
|
||||
|
||||
def subscribe(service, action):
|
||||
|
|
Loading…
Add table
Reference in a new issue