From a02840379d56999a1755fb5dad952e92a091399a Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 1 Mar 2016 10:49:38 -0800 Subject: [PATCH 1/2] Track WeMo devices by serial number This makes us track WeMo devices by serial number instead of URL. Per @jaharkes' suggestion, tracking via URL could potentially be a problem if a device changes to another IP and then appears to be discovered again. Since we can't track based on mac (for static-configured devices), we can use the serial number exposed to make sure we're always looking at a list of unique devices. --- homeassistant/components/wemo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index e6fc88bea1a..35603b21d64 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -58,12 +58,13 @@ def setup(hass, config): def discovery_dispatch(service, discovery_info): """Dispatcher for WeMo discovery events.""" # name, model, location, mac - _, model_name, url, _ = discovery_info + _, model_name, _, _, serial = discovery_info # Only register a device once - if url in KNOWN_DEVICES: + if serial in KNOWN_DEVICES: return - KNOWN_DEVICES.append(url) + _LOGGER.debug('Discovered unique device %s', serial) + KNOWN_DEVICES.append(serial) service = WEMO_MODEL_DISPATCH.get(model_name) or DISCOVER_SWITCHES component = WEMO_SERVICE_DISPATCH.get(service) @@ -91,6 +92,7 @@ def setup(hass, config): if device is None: device = pywemo.discovery.device_from_description(url, None) - discovery_info = (device.name, device.model_name, url, device.mac) + discovery_info = (device.name, device.model_name, url, device.mac, + device.serialnumber) discovery.discover(hass, discovery.SERVICE_WEMO, discovery_info) return True From bbd3a4358575b88fb5ea250fdc8dd90deac4668a Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Tue, 1 Mar 2016 23:25:18 -0500 Subject: [PATCH 2/2] Update netdisco to 0.5.4 --- homeassistant/components/discovery.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/discovery.py b/homeassistant/components/discovery.py index c1a3c5046fd..63706d26a19 100644 --- a/homeassistant/components/discovery.py +++ b/homeassistant/components/discovery.py @@ -15,7 +15,7 @@ from homeassistant.const import ( EVENT_PLATFORM_DISCOVERED) DOMAIN = "discovery" -REQUIREMENTS = ['netdisco==0.5.3'] +REQUIREMENTS = ['netdisco==0.5.4'] SCAN_INTERVAL = 300 # seconds diff --git a/requirements_all.txt b/requirements_all.txt index e2087f79a76..fa05b7022cf 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -116,7 +116,7 @@ limitlessled==1.0.0 mficlient==0.3.0 # homeassistant.components.discovery -netdisco==0.5.3 +netdisco==0.5.4 # homeassistant.components.sensor.neurio_energy neurio==0.2.10