Allow disabling WeMo Discovery (#18079)
* WeMo - Disable Discovery - New config option * WeMo - Disable Discovery - Change log level to debug * WeMo - Disable Discovery - Change logging level
This commit is contained in:
parent
6a5f9faa33
commit
5c99862878
1 changed files with 15 additions and 7 deletions
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -136,13 +141,16 @@ def setup(hass, config):
|
|||
|
||||
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,
|
||||
|
|
Loading…
Add table
Reference in a new issue