Avoid Sonos error during startup (#10146)
* Add Sonos coordinators before slaves
This commit is contained in:
parent
9eaa057739
commit
6cadb796bc
1 changed files with 8 additions and 2 deletions
|
@ -150,8 +150,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
_LOGGER.warning("No Sonos speakers found")
|
_LOGGER.warning("No Sonos speakers found")
|
||||||
return
|
return
|
||||||
|
|
||||||
hass.data[DATA_SONOS] = [SonosDevice(p) for p in players]
|
# Add coordinators first so they can be queried by slaves
|
||||||
add_devices(hass.data[DATA_SONOS], True)
|
coordinators = [SonosDevice(p) for p in players if p.is_coordinator]
|
||||||
|
slaves = [SonosDevice(p) for p in players if not p.is_coordinator]
|
||||||
|
hass.data[DATA_SONOS] = coordinators + slaves
|
||||||
|
if coordinators:
|
||||||
|
add_devices(coordinators, True)
|
||||||
|
if slaves:
|
||||||
|
add_devices(slaves, True)
|
||||||
_LOGGER.info("Added %s Sonos speakers", len(players))
|
_LOGGER.info("Added %s Sonos speakers", len(players))
|
||||||
|
|
||||||
descriptions = load_yaml_config_file(
|
descriptions = load_yaml_config_file(
|
||||||
|
|
Loading…
Add table
Reference in a new issue