mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Sonos fix media player join to avoid race condition (#159106)
This commit is contained in:
@@ -1015,11 +1015,21 @@ class SonosSpeaker:
|
|||||||
speakers: list[SonosSpeaker],
|
speakers: list[SonosSpeaker],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Form a group with other players."""
|
"""Form a group with other players."""
|
||||||
|
# When joining multiple speakers, build the group incrementally and
|
||||||
|
# wait for the grouping to complete after each join. This avoids race
|
||||||
|
# conditions in zone topology updates.
|
||||||
async with config_entry.runtime_data.topology_condition:
|
async with config_entry.runtime_data.topology_condition:
|
||||||
group: list[SonosSpeaker] = await hass.async_add_executor_job(
|
join_list: list[SonosSpeaker] = []
|
||||||
master.join, speakers
|
for speaker in speakers:
|
||||||
)
|
_LOGGER.debug("Join %s to %s", speaker.zone_name, master.zone_name)
|
||||||
await SonosSpeaker.wait_for_groups(hass, config_entry, [group])
|
join_list.append(speaker)
|
||||||
|
group: list[SonosSpeaker] = await hass.async_add_executor_job(
|
||||||
|
master.join, join_list
|
||||||
|
)
|
||||||
|
await SonosSpeaker.wait_for_groups(hass, config_entry, [group])
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Join Complete %s to %s", speaker.zone_name, master.zone_name
|
||||||
|
)
|
||||||
|
|
||||||
@soco_error()
|
@soco_error()
|
||||||
def unjoin(self) -> None:
|
def unjoin(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user