Use shorthand attributes in Snapcast (#99840)

This commit is contained in:
Joost Lekkerkerker 2023-09-07 16:37:30 +02:00 committed by GitHub
parent d9b48b03f7
commit 73651dbffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 15 deletions

View File

@ -160,7 +160,7 @@ class SnapcastGroupDevice(MediaPlayerEntity):
self._attr_available = True
self._group = group
self._entry_id = entry_id
self._uid = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}"
self._attr_unique_id = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}"
async def async_added_to_hass(self) -> None:
"""Subscribe to group events."""
@ -184,11 +184,6 @@ class SnapcastGroupDevice(MediaPlayerEntity):
return MediaPlayerState.IDLE
return STREAM_STATUS.get(self._group.stream_status)
@property
def unique_id(self):
"""Return the ID of snapcast group."""
return self._uid
@property
def identifier(self):
"""Return the snapcast identifier."""
@ -260,7 +255,8 @@ class SnapcastClientDevice(MediaPlayerEntity):
"""Initialize the Snapcast client device."""
self._attr_available = True
self._client = client
self._uid = f"{CLIENT_PREFIX}{uid_part}_{self._client.identifier}"
# Note: Host part is needed, when using multiple snapservers
self._attr_unique_id = f"{CLIENT_PREFIX}{uid_part}_{self._client.identifier}"
self._entry_id = entry_id
async def async_added_to_hass(self) -> None:
@ -278,14 +274,6 @@ class SnapcastClientDevice(MediaPlayerEntity):
self._attr_available = available
self.schedule_update_ha_state()
@property
def unique_id(self):
"""Return the ID of this snapcast client.
Note: Host part is needed, when using multiple snapservers
"""
return self._uid
@property
def identifier(self):
"""Return the snapcast identifier."""