From da2bcb3f27e7fec77666c55bca2f208bf7212376 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Sat, 27 Feb 2016 20:11:32 -0800 Subject: [PATCH 1/3] Fix static configured wemo devices The new wemo code was pulling 'static' from the global config instead of the wemo component config. --- homeassistant/components/wemo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index 9dc144266a8..e7fb426fe37 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -77,7 +77,8 @@ def setup(hass, config): devices = [(device.host, device) for device in pywemo.discover_devices()] # Add static devices from the config file - devices.extend((address, None) for address in config.get('static', [])) + devices.extend((address, None) + for address in config['wemo'].get('static', [])) for address, device in devices: port = pywemo.ouimeaux_device.probe_wemo(address) From 3790764df9d56697f5dd0aeb8a73130de6e8df89 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Sat, 27 Feb 2016 20:33:35 -0800 Subject: [PATCH 2/3] Fix wemo known device tracking The wemo component was tracking devices by mac to avoid adding duplicates, but this means we'd never be able to load more than one static wemo, since they all have mac=None. This changes the code to track by url, which has to be unique per wemo anyway, and which we also have for even static wemos. --- homeassistant/components/wemo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index e7fb426fe37..0427815c6e1 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -58,12 +58,12 @@ def setup(hass, config): def discovery_dispatch(service, discovery_info): """Dispatcher for WeMo discovery events.""" # name, model, location, mac - _, model_name, _, mac = discovery_info + _, model_name, url, _ = discovery_info # Only register a device once - if mac in KNOWN_DEVICES: + if url in KNOWN_DEVICES: return - KNOWN_DEVICES.append(mac) + KNOWN_DEVICES.append(url) service = WEMO_MODEL_DISPATCH.get(model_name) or DISCOVER_SWITCHES component = WEMO_SERVICE_DISPATCH.get(service) From 34b463f435224d0fffa63880b2a9eb6187667a54 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Sun, 28 Feb 2016 07:45:34 -0800 Subject: [PATCH 3/3] Gracefully handle having no wemo config section I broke this with my fix, where I assumed that we'd always have a wemo config section if we're running the wemo code. However, if we're fully auto-detected, we might not. --- homeassistant/components/wemo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index 0427815c6e1..e6fc88bea1a 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -78,7 +78,7 @@ def setup(hass, config): # Add static devices from the config file devices.extend((address, None) - for address in config['wemo'].get('static', [])) + for address in config.get(DOMAIN, {}).get('static', [])) for address, device in devices: port = pywemo.ouimeaux_device.probe_wemo(address)