mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Merge pull request #1208 from kk7ds/static-wemos
Support manually-defined WeMo devices
This commit is contained in:
commit
ee62c2cc2b
@ -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. """
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user