Remove discovery (#17070)

This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2018-10-04 16:04:44 +02:00
1 parent 02bf07d9df
commit 769dda735d
2 files changed
+5 -87

No files matched your search

+5 -31
View File
@@ -12,9 +12,9 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_FILENAME, CONF_HOST
from homeassistant.helpers import (
aiohttp_client, config_validation as cv, device_registry as dr)
config_validation as cv, device_registry as dr)
from .const import DOMAIN, API_NUPNP
from .const import DOMAIN
from .bridge import HueBridge
# Loading the config flow file will register the flow
from .config_flow import configured_hosts
@@ -62,37 +62,11 @@ async def async_setup(hass, config):
configured = configured_hosts(hass)
# User has configured bridges
if CONF_BRIDGES in conf:
bridges = conf[CONF_BRIDGES]
# Component is part of config but no bridges specified, discover.
elif DOMAIN in config:
# discover from nupnp
websession = aiohttp_client.async_get_clientsession(hass)
async with websession.get(API_NUPNP) as req:
hosts = await req.json()
bridges = []
for entry in hosts:
# Filter out already configured hosts
if entry['internalipaddress'] in configured:
continue
# Run through config schema to populate defaults
bridges.append(BRIDGE_CONFIG_SCHEMA({
CONF_HOST: entry['internalipaddress'],
# Careful with using entry['id'] for other reasons. The
# value is in lowercase but is returned uppercase from hub.
CONF_FILENAME: '.hue_{}.conf'.format(entry['id']),
}))
else:
# Component not specified in config, we're loaded via discovery
bridges = []
if not bridges:
if CONF_BRIDGES not in conf:
return True
bridges = conf[CONF_BRIDGES]
for bridge_conf in bridges:
host = bridge_conf[CONF_HOST]