From 6578928e3c22df83854dbd8d2c747d4815935530 Mon Sep 17 00:00:00 2001 From: Alexander Fortin Date: Thu, 18 Feb 2016 18:57:09 +0100 Subject: [PATCH] Fix media_player/sonos configuration mismatch * From configuration.yaml is easy to provide iterable elements like lists, this adds the possibility to provide a list of Sonos hosts using a yaml and still supports the comma separated string version * Remove superfluous host reassignment --- homeassistant/components/media_player/sonos.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/sonos.py b/homeassistant/components/media_player/sonos.py index 35c5e360bf0..7a66c3d354c 100644 --- a/homeassistant/components/media_player/sonos.py +++ b/homeassistant/components/media_player/sonos.py @@ -47,10 +47,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): players = None hosts = config.get('hosts', None) if hosts: + # Support retro compatibility with comma separated list of hosts + # from config + hosts = hosts.split(',') if isinstance(hosts, str) else hosts players = [] - for host in hosts.split(","): - host = socket.gethostbyname(host) - players.append(soco.SoCo(host)) + for host in hosts: + players.append(soco.SoCo(socket.gethostbyname(host))) if not players: players = soco.discover(interface_addr=config.get('interface_addr',