Bugfix sonos (#3926)

* Bugfix Sonos

* lint

* Use player uid for looking of exists

* fix lint

* fix unittest

* Change player_id to unique_id
This commit is contained in:
Pascal Vizeli 2016-10-20 17:36:48 +02:00 committed by Paulus Schoutsen
parent d60c2d604f
commit c32afcd961
2 changed files with 14 additions and 0 deletions

View File

@ -62,6 +62,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if discovery_info:
player = soco.SoCo(discovery_info)
# if device allready exists by config
if player.uid in DEVICES:
return True
if player.is_visible:
device = SonosDevice(hass, player)
add_devices([device])
@ -212,6 +217,11 @@ class SonosDevice(MediaPlayerDevice):
"""Update state, called by track_utc_time_change."""
self.update_ha_state(True)
@property
def unique_id(self):
"""Return an unique ID."""
return self._player.uid
@property
def name(self):
"""Return the name of the device."""

View File

@ -67,6 +67,10 @@ class SoCoMock():
"""Cause the speaker to separate itself from other speakers."""
return
def uid(self):
"""Return a player uid."""
return "RINCON_XXXXXXXXXXXXXXXXX"
class TestSonosMediaPlayer(unittest.TestCase):
"""Test the media_player module."""