Use standard attribute for Sonos group members (#70924)

This commit is contained in:
jjlawren 2022-04-27 11:59:05 -05:00 committed by GitHub
parent b17d27262c
commit 6151306e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,8 +76,6 @@ REPEAT_TO_SONOS = {
SONOS_TO_REPEAT = {meaning: mode for mode, meaning in REPEAT_TO_SONOS.items()} SONOS_TO_REPEAT = {meaning: mode for mode, meaning in REPEAT_TO_SONOS.items()}
ATTR_SONOS_GROUP = "sonos_group"
UPNP_ERRORS_TO_IGNORE = ["701", "711", "712"] UPNP_ERRORS_TO_IGNORE = ["701", "711", "712"]
SERVICE_JOIN = "join" SERVICE_JOIN = "join"
@ -265,6 +263,11 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
"""Return the current coordinator SonosSpeaker.""" """Return the current coordinator SonosSpeaker."""
return self.speaker.coordinator or self.speaker return self.speaker.coordinator or self.speaker
@property
def group_members(self) -> list[str] | None:
"""List of entity_ids which are currently grouped together."""
return self.speaker.sonos_group_entities
def __hash__(self) -> int: def __hash__(self) -> int:
"""Return a hash of self.""" """Return a hash of self."""
return hash(self.unique_id) return hash(self.unique_id)
@ -654,9 +657,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
@property @property
def extra_state_attributes(self) -> dict[str, Any]: def extra_state_attributes(self) -> dict[str, Any]:
"""Return entity specific state attributes.""" """Return entity specific state attributes."""
attributes: dict[str, Any] = { attributes: dict[str, Any] = {}
ATTR_SONOS_GROUP: self.speaker.sonos_group_entities
}
if self.media.queue_position is not None: if self.media.queue_position is not None:
attributes[ATTR_QUEUE_POSITION] = self.media.queue_position attributes[ATTR_QUEUE_POSITION] = self.media.queue_position