1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-19 18:38:58 +00:00

Sonos fix media player join to avoid race condition (#159106)

This commit is contained in:
Pete Sage
2025-12-15 14:04:55 -05:00
committed by GitHub
parent d51cca3325
commit c69ef7e1f6

View File

@@ -1015,11 +1015,21 @@ class SonosSpeaker:
speakers: list[SonosSpeaker],
) -> None:
"""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:
group: list[SonosSpeaker] = await hass.async_add_executor_job(
master.join, speakers
)
await SonosSpeaker.wait_for_groups(hass, config_entry, [group])
join_list: list[SonosSpeaker] = []
for speaker in speakers:
_LOGGER.debug("Join %s to %s", speaker.zone_name, master.zone_name)
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()
def unjoin(self) -> None: