Improve Sonos terminology for inclusiveness (#71206)

* Improve Sonos group terminology

* Deprecate Sonos-specific grouping services

* Push deprecation back one version

* Revert deprecation notice
This commit is contained in:
jjlawren 2022-05-03 01:01:19 -05:00 committed by GitHub
parent 29bda196b5
commit 9b03ef4829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -749,18 +749,18 @@ class SonosSpeaker:
def _get_soco_group() -> list[str]:
"""Ask SoCo cache for existing topology."""
coordinator_uid = self.soco.uid
slave_uids = []
joined_uids = []
with contextlib.suppress(OSError, SoCoException):
if self.soco.group and self.soco.group.coordinator:
coordinator_uid = self.soco.group.coordinator.uid
slave_uids = [
joined_uids = [
p.uid
for p in self.soco.group.members
if p.uid != coordinator_uid and p.is_visible
]
return [coordinator_uid] + slave_uids
return [coordinator_uid] + joined_uids
async def _async_extract_group(event: SonosEvent | None) -> list[str]:
"""Extract group layout from a topology event."""
@ -814,13 +814,13 @@ class SonosSpeaker:
self.sonos_group_entities = sonos_group_entities
self.async_write_entity_states()
for slave_uid in group[1:]:
slave = self.hass.data[DATA_SONOS].discovered.get(slave_uid)
if slave:
slave.coordinator = self
slave.sonos_group = sonos_group
slave.sonos_group_entities = sonos_group_entities
slave.async_write_entity_states()
for joined_uid in group[1:]:
joined_speaker = self.hass.data[DATA_SONOS].discovered.get(joined_uid)
if joined_speaker:
joined_speaker.coordinator = self
joined_speaker.sonos_group = sonos_group
joined_speaker.sonos_group_entities = sonos_group_entities
joined_speaker.async_write_entity_states()
_LOGGER.debug("Regrouped %s: %s", self.zone_name, self.sonos_group_entities)
@ -838,7 +838,7 @@ class SonosSpeaker:
return _async_handle_group_event(event)
@soco_error()
def join(self, slaves: list[SonosSpeaker]) -> list[SonosSpeaker]:
def join(self, speakers: list[SonosSpeaker]) -> list[SonosSpeaker]:
"""Form a group with other players."""
if self.coordinator:
self.unjoin()
@ -846,12 +846,12 @@ class SonosSpeaker:
else:
group = self.sonos_group.copy()
for slave in slaves:
if slave.soco.uid != self.soco.uid:
slave.soco.join(self.soco)
slave.coordinator = self
if slave not in group:
group.append(slave)
for speaker in speakers:
if speaker.soco.uid != self.soco.uid:
speaker.soco.join(self.soco)
speaker.coordinator = self
if speaker not in group:
group.append(speaker)
return group
@ -880,11 +880,11 @@ class SonosSpeaker:
def _unjoin_all(speakers: list[SonosSpeaker]) -> None:
"""Sync helper."""
# Unjoin slaves first to prevent inheritance of queues
# Detach all joined speakers first to prevent inheritance of queues
coordinators = [s for s in speakers if s.is_coordinator]
slaves = [s for s in speakers if not s.is_coordinator]
joined_speakers = [s for s in speakers if not s.is_coordinator]
for speaker in slaves + coordinators:
for speaker in joined_speakers + coordinators:
speaker.unjoin()
async with hass.data[DATA_SONOS].topology_condition:
@ -928,7 +928,7 @@ class SonosSpeaker:
assert self.soco_snapshot is not None
self.soco_snapshot.restore()
except (TypeError, AssertionError, AttributeError, SoCoException) as ex:
# Can happen if restoring a coordinator onto a current slave
# Can happen if restoring a coordinator onto a current group member
_LOGGER.warning("Error on restore %s: %s", self.zone_name, ex)
self.soco_snapshot = None
@ -1036,7 +1036,7 @@ class SonosSpeaker:
if coordinator != current_group[0]:
return False
# Test that slaves match
# Test that joined members match
if set(group[1:]) != set(current_group[1:]):
return False