Merge pull request #1458 from jaharkes/track-wemos-by-serial

Track wemos by serial
This commit is contained in:
Paulus Schoutsen 2016-03-02 23:10:13 -08:00
commit 1e3199eb8c
3 changed files with 8 additions and 6 deletions

View File

@ -15,7 +15,7 @@ from homeassistant.const import (
EVENT_PLATFORM_DISCOVERED) EVENT_PLATFORM_DISCOVERED)
DOMAIN = "discovery" DOMAIN = "discovery"
REQUIREMENTS = ['netdisco==0.5.3'] REQUIREMENTS = ['netdisco==0.5.4']
SCAN_INTERVAL = 300 # seconds SCAN_INTERVAL = 300 # seconds

View File

@ -58,12 +58,13 @@ def setup(hass, config):
def discovery_dispatch(service, discovery_info): def discovery_dispatch(service, discovery_info):
"""Dispatcher for WeMo discovery events.""" """Dispatcher for WeMo discovery events."""
# name, model, location, mac # name, model, location, mac
_, model_name, url, _ = discovery_info _, model_name, _, _, serial = discovery_info
# Only register a device once # Only register a device once
if url in KNOWN_DEVICES: if serial in KNOWN_DEVICES:
return 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 service = WEMO_MODEL_DISPATCH.get(model_name) or DISCOVER_SWITCHES
component = WEMO_SERVICE_DISPATCH.get(service) component = WEMO_SERVICE_DISPATCH.get(service)
@ -91,6 +92,7 @@ def setup(hass, config):
if device is None: if device is None:
device = pywemo.discovery.device_from_description(url, 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) discovery.discover(hass, discovery.SERVICE_WEMO, discovery_info)
return True return True

View File

@ -116,7 +116,7 @@ limitlessled==1.0.0
mficlient==0.3.0 mficlient==0.3.0
# homeassistant.components.discovery # homeassistant.components.discovery
netdisco==0.5.3 netdisco==0.5.4
# homeassistant.components.sensor.neurio_energy # homeassistant.components.sensor.neurio_energy
neurio==0.2.10 neurio==0.2.10