mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Merge pull request #937 from trollkarlen/sonos-multicast
sonos: add hosts and interface_addr to sonos config
This commit is contained in:
commit
1098194a89
@ -38,12 +38,23 @@ SUPPORT_SONOS = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE |\
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Sonos platform. """
|
""" Sets up the Sonos platform. """
|
||||||
import soco
|
import soco
|
||||||
|
import socket
|
||||||
|
|
||||||
if discovery_info:
|
if discovery_info:
|
||||||
add_devices([SonosDevice(hass, soco.SoCo(discovery_info))])
|
add_devices([SonosDevice(hass, soco.SoCo(discovery_info))])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
players = soco.discover()
|
players = None
|
||||||
|
hosts = config.get('hosts', None)
|
||||||
|
if hosts:
|
||||||
|
players = []
|
||||||
|
for host in hosts.split(","):
|
||||||
|
host = socket.gethostbyname(host)
|
||||||
|
players.append(soco.SoCo(host))
|
||||||
|
|
||||||
|
if not players:
|
||||||
|
players = soco.discover(interface_addr=config.get('interface_addr',
|
||||||
|
None))
|
||||||
|
|
||||||
if not players:
|
if not players:
|
||||||
_LOGGER.warning('No Sonos speakers found.')
|
_LOGGER.warning('No Sonos speakers found.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user