diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index 1d569449ff7..43c325795c6 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -12,7 +12,7 @@ from homeassistant.components.switch import SwitchDevice from homeassistant.const import ( STATE_ON, STATE_OFF, STATE_STANDBY, EVENT_HOMEASSISTANT_STOP) -REQUIREMENTS = ['pywemo==0.3.9'] +REQUIREMENTS = ['pywemo==0.3.10'] _LOGGER = logging.getLogger(__name__) _WEMO_SUBSCRIPTION_REGISTRY = None @@ -24,6 +24,17 @@ MAKER_SWITCH_MOMENTARY = "momentary" MAKER_SWITCH_TOGGLE = "toggle" +def _find_manual_wemos(pywemo, static_config): + for address in static_config: + port = pywemo.ouimeaux_device.probe_wemo(address) + if not port: + _LOGGER.warning('Unable to probe wemo at %s', address) + continue + _LOGGER.info('Adding static wemo at %s:%i', address, port) + url = 'http://%s:%i/setup.xml' % (address, port) + yield pywemo.discovery.device_from_description(url, None) + + # pylint: disable=unused-argument, too-many-function-args def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return WeMo switches. """ @@ -60,6 +71,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): [WemoSwitch(switch) for switch in switches if isinstance(switch, pywemo.Switch)]) + # Add manually-defined wemo devices + if discovery_info is None and 'static' in config: + add_devices_callback( + [WemoSwitch(wemo) + for wemo in _find_manual_wemos(pywemo, config['static'])]) + class WemoSwitch(SwitchDevice): """ Represents a WeMo switch. """ diff --git a/requirements_all.txt b/requirements_all.txt index 5ea5c6ec73f..1a032958157 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -210,7 +210,7 @@ pyuserinput==0.1.9 pyvera==0.2.8 # homeassistant.components.switch.wemo -pywemo==0.3.9 +pywemo==0.3.10 # homeassistant.components.thermostat.radiotherm radiotherm==1.2