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