mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
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:
parent
d60c2d604f
commit
c32afcd961
@ -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."""
|
||||
|
@ -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."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user