Merge pull request #686 from balloob/sonos-fix

Have Sonos work nicer with discovery
pull/692/head
Jeff Schroeder 2015-12-01 22:44:58 -06:00
commit 587ef04560
1 changed files with 6 additions and 1 deletions

View File

@ -39,9 +39,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Sonos platform. """
import soco
if discovery_info:
add_devices([SonosDevice(hass, soco.SoCo(discovery_info))])
return True
players = soco.discover()
if not players:
_LOGGER.warning('No Sonos speakers found. Disabling: %s', __name__)
_LOGGER.warning('No Sonos speakers found.')
return False
add_devices(SonosDevice(hass, p) for p in players)