Skip to content

Commit

Permalink
Fix WeMo incorrect mapping of device type during discovery (home-assi…
Browse files Browse the repository at this point in the history
  • Loading branch information
sqldiablo authored and MartinHjelmare committed Jan 3, 2019
1 parent 87a0118 commit ada0f7c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions homeassistant/components/wemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

DOMAIN = 'wemo'

# Mapping from Wemo model_name to component.
WEMO_MODEL_DISPATCH = {
# Mapping from Wemo device type to Home Assistant component type.
WEMO_DEVICE_TYPE_DISPATCH = {
'Bridge': 'light',
'CoffeeMaker': 'switch',
'Dimmer': 'light',
Expand All @@ -30,8 +30,7 @@
'LightSwitch': 'switch',
'Maker': 'switch',
'Motion': 'binary_sensor',
'Sensor': 'binary_sensor',
'Socket': 'switch'
'Switch': 'switch'
}

SUBSCRIPTION_REGISTRY = None
Expand Down Expand Up @@ -110,7 +109,7 @@ def setup_url_for_address(host, port):
def discovery_dispatch(service, discovery_info):
"""Dispatcher for incoming WeMo discovery events."""
# name, model, location, mac
model_name = discovery_info.get('model_name')
device_type = discovery_info.get('device_type')
serial = discovery_info.get('serial')

# Only register a device once
Expand All @@ -122,7 +121,7 @@ def discovery_dispatch(service, discovery_info):
_LOGGER.debug('Discovered unique WeMo device: %s', serial)
KNOWN_DEVICES.append(serial)

component = WEMO_MODEL_DISPATCH.get(model_name, 'switch')
component = WEMO_DEVICE_TYPE_DISPATCH.get(device_type, 'switch')

discovery.load_platform(hass, component, DOMAIN,
discovery_info, config)
Expand Down Expand Up @@ -166,7 +165,7 @@ def discover_wemo_devices(now):
device.host, device.port)

discovery_info = {
'model_name': device.model_name,
'device_type': device.__class__.__name__,
'serial': device.serialnumber,
'mac_address': device.mac,
'ssdp_description': url,
Expand Down

0 comments on commit ada0f7c

Please sign in to comment.