Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squeezebox: Keep track of already added players #7149

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions homeassistant/components/media_player/squeezebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
DEFAULT_PORT = 9000
TIMEOUT = 10

KNOWN_DEVICES = []

SUPPORT_SQUEEZEBOX = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | \
SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
SUPPORT_SEEK | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PLAY_MEDIA | \
Expand Down Expand Up @@ -71,18 +69,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
host, port, error)
return False

# Combine it with port to allow multiple servers at the same host
key = "{}:{}".format(ipaddr, port)

# Only add a media server once
if key in KNOWN_DEVICES:
return False
KNOWN_DEVICES.append(key)

_LOGGER.debug("Creating LMS object for %s", ipaddr)
lms = LogitechMediaServer(hass, host, port, username, password)
if lms is False:
return False

players = yield from lms.create_players()
async_add_devices(players)
Expand Down Expand Up @@ -173,6 +161,11 @@ def name(self):
"""Return the name of the device."""
return self._name

@property
def unique_id(self):
"""Return an unique ID."""
return self._id

@property
def state(self):
"""Return the state of the device."""
Expand Down