Skip to content

Commit

Permalink
Allow disabling WeMo Discovery (#18079)
Browse files Browse the repository at this point in the history
* WeMo - Disable Discovery - New config option

* WeMo - Disable Discovery - Change log level to debug

* WeMo - Disable Discovery - Change logging level
  • Loading branch information
sqldiablo authored and bachya committed Nov 3, 2018
1 parent 6a5f9fa commit 5c99862
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions homeassistant/components/wemo.py
Expand Up @@ -58,12 +58,17 @@ def coerce_host_port(value):


CONF_STATIC = 'static'
CONF_DISABLE_DISCOVERY = 'disable_discovery'

DEFAULT_DISABLE_DISCOVERY = False

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Optional(CONF_STATIC, default=[]): vol.Schema([
vol.All(cv.string, coerce_host_port)
])
]),
vol.Optional(CONF_DISABLE_DISCOVERY,
default=DEFAULT_DISABLE_DISCOVERY): cv.boolean
}),
}, extra=vol.ALLOW_EXTRA)

Expand All @@ -78,7 +83,7 @@ def setup(hass, config):

def stop_wemo(event):
"""Shutdown Wemo subscriptions and subscription thread on exit."""
_LOGGER.info("Shutting down subscriptions.")
_LOGGER.debug("Shutting down subscriptions.")
SUBSCRIPTION_REGISTRY.stop()

hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_wemo)
Expand Down Expand Up @@ -136,13 +141,16 @@ def setup_url_for_address(host, port):

devices.append((url, device))

_LOGGER.info("Scanning for WeMo devices.")
devices.extend(
(setup_url_for_device(device), device)
for device in pywemo.discover_devices())
disable_discovery = config.get(DOMAIN, {}).get(CONF_DISABLE_DISCOVERY)

if not disable_discovery:
_LOGGER.debug("Scanning for WeMo devices.")
devices.extend(
(setup_url_for_device(device), device)
for device in pywemo.discover_devices())

for url, device in devices:
_LOGGER.info('Adding wemo at %s:%i', device.host, device.port)
_LOGGER.debug('Adding wemo at %s:%i', device.host, device.port)

discovery_info = {
'model_name': device.model_name,
Expand Down

0 comments on commit 5c99862

Please sign in to comment.