Add entity registry support to media_player.snapcast (#14895)

Unique id for client is generated from prefix 'snapcast_client_'
and MAC address

Unique id for group is generated from prefix 'snapcast_group_'
and UUID provided by snapcast library
pull/14905/head
Ing. Jaroslav Šafka 2018-06-10 08:31:42 +02:00 committed by Martin Hjelmare
parent bc0d0751b9
commit 20caeb5383
1 changed files with 10 additions and 0 deletions

View File

@ -104,6 +104,11 @@ class SnapcastGroupDevice(MediaPlayerDevice):
'unknown': STATE_UNKNOWN,
}.get(self._group.stream_status, STATE_UNKNOWN)
@property
def unique_id(self):
"""Return the ID of snapcast group."""
return '{}{}'.format(GROUP_PREFIX, self._group.identifier)
@property
def name(self):
"""Return the name of the device."""
@ -185,6 +190,11 @@ class SnapcastClientDevice(MediaPlayerDevice):
client.set_callback(self.schedule_update_ha_state)
self._client = client
@property
def unique_id(self):
"""Return the ID of this snapcast client."""
return '{}{}'.format(CLIENT_PREFIX, self._client.identifier)
@property
def name(self):
"""Return the name of the device."""