WeMo - Fix device discovery issues (#20446)

This commit is contained in:
Adam Belebczuk 2019-01-26 05:00:06 -05:00 committed by Fabian Affolter
parent d39784906b
commit 310c073c64

View File

@ -20,8 +20,8 @@ REQUIREMENTS = ['pywemo==0.4.34']
DOMAIN = 'wemo'
# Mapping from Wemo device type to Home Assistant component type.
WEMO_DEVICE_TYPE_DISPATCH = {
# Mapping from Wemo model_name to component.
WEMO_MODEL_DISPATCH = {
'Bridge': 'light',
'CoffeeMaker': 'switch',
'Dimmer': 'light',
@ -30,7 +30,8 @@ WEMO_DEVICE_TYPE_DISPATCH = {
'LightSwitch': 'switch',
'Maker': 'switch',
'Motion': 'binary_sensor',
'Switch': 'switch'
'Sensor': 'binary_sensor',
'Socket': 'switch'
}
SUBSCRIPTION_REGISTRY = None
@ -109,7 +110,7 @@ def setup(hass, config):
def discovery_dispatch(service, discovery_info):
"""Dispatcher for incoming WeMo discovery events."""
# name, model, location, mac
device_type = discovery_info.get('device_type')
model_name = discovery_info.get('model_name')
serial = discovery_info.get('serial')
# Only register a device once
@ -121,7 +122,7 @@ def setup(hass, config):
_LOGGER.debug('Discovered unique WeMo device: %s', serial)
KNOWN_DEVICES.append(serial)
component = WEMO_DEVICE_TYPE_DISPATCH.get(device_type, 'switch')
component = WEMO_MODEL_DISPATCH.get(model_name, 'switch')
discovery.load_platform(hass, component, DOMAIN,
discovery_info, config)
@ -165,7 +166,7 @@ def setup(hass, config):
device.host, device.port)
discovery_info = {
'device_type': device.__class__.__name__,
'model_name': device.model_name,
'serial': device.serialnumber,
'mac_address': device.mac,
'ssdp_description': url,