From ce22f3c82dd7d36c6b2fffa5860f91ad2ccbc58e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 13 Sep 2015 16:52:15 -0400 Subject: [PATCH 1/2] Implement unique_id to prevent duplicate devices --- .../components/frontend/www_static/home-assistant-polymer | 2 +- homeassistant/components/media_player/sonos.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/frontend/www_static/home-assistant-polymer b/homeassistant/components/frontend/www_static/home-assistant-polymer index 9637d5d2651..b0b12e20e0f 160000 --- a/homeassistant/components/frontend/www_static/home-assistant-polymer +++ b/homeassistant/components/frontend/www_static/home-assistant-polymer @@ -1 +1 @@ -Subproject commit 9637d5d26516873b8a04a3c62b9596163c822a2d +Subproject commit b0b12e20e0f61df849c414c2dfbcf9923f784631 diff --git a/homeassistant/components/media_player/sonos.py b/homeassistant/components/media_player/sonos.py index 3deacd84e10..058a676ebc8 100644 --- a/homeassistant/components/media_player/sonos.py +++ b/homeassistant/components/media_player/sonos.py @@ -78,6 +78,11 @@ class SonosDevice(MediaPlayerDevice): """ Returns the name of the device. """ return self._name + @property + def unique_id(self): + """ Returns a unique id. """ + return "{}.{}".format(self.__class__, self._player.uid) + @property def state(self): """ Returns the state of the device. """ From d4834ff408cef0080b9105cde3f9e3766ccdfa2d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 13 Sep 2015 16:53:05 -0400 Subject: [PATCH 2/2] Add hass property to Entity to prevent 'Attribute hass is None' error during self.update_ha_state --- homeassistant/components/media_player/sonos.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/media_player/sonos.py b/homeassistant/components/media_player/sonos.py index 058a676ebc8..1f299486047 100644 --- a/homeassistant/components/media_player/sonos.py +++ b/homeassistant/components/media_player/sonos.py @@ -57,6 +57,7 @@ class SonosDevice(MediaPlayerDevice): # pylint: disable=too-many-arguments def __init__(self, hass, player): + self.hass = hass super(SonosDevice, self).__init__() self._player = player self.update()