From 20caeb5383b4ca1f4a0140a105c19d4ea1bdf389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ing=2E=20Jaroslav=20=C5=A0afka?= Date: Sun, 10 Jun 2018 08:31:42 +0200 Subject: [PATCH] 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 --- homeassistant/components/media_player/snapcast.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/homeassistant/components/media_player/snapcast.py b/homeassistant/components/media_player/snapcast.py index 793800a3d22..ca7ff17a16a 100644 --- a/homeassistant/components/media_player/snapcast.py +++ b/homeassistant/components/media_player/snapcast.py @@ -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."""