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

Introduce zone_id to identify player+zone #12382

Merged
merged 1 commit into from
Feb 13, 2018
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
11 changes: 8 additions & 3 deletions homeassistant/components/media_player/yamaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import rxv
# Keep track of configured receivers so that we don't end up
# discovering a receiver dynamically that we have static config
# for. Map each device from its unique_id to an instance since
# for. Map each device from its zone_id to an instance since
# YamahaDevice is not hashable (thus not possible to add to a set).
if hass.data.get(DATA_YAMAHA) is None:
hass.data[DATA_YAMAHA] = {}
Expand Down Expand Up @@ -100,8 +100,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
source_names, zone_names)

# Only add device if it's not already added
if device.unique_id not in hass.data[DATA_YAMAHA]:
hass.data[DATA_YAMAHA][device.unique_id] = device
if device.zone_id not in hass.data[DATA_YAMAHA]:
hass.data[DATA_YAMAHA][device.zone_id] = device
devices.append(device)
else:
_LOGGER.debug('Ignoring duplicate receiver %s', name)
Expand Down Expand Up @@ -220,6 +220,11 @@ def source_list(self):
"""List of available input sources."""
return self._source_list

@property
def zone_id(self):
"""Return an zone_id to ensure 1 media player per zone."""
return '{0}:{1}'.format(self.receiver.ctrl_url, self._zone)

@property
def supported_features(self):
"""Flag media player features that are supported."""
Expand Down