Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions homeassistant/components/hue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
CONF_ALLOW_UNREACHABLE = 'allow_unreachable'
DEFAULT_ALLOW_UNREACHABLE = False

DATA_CONFIGS = 'hue_configs'

PHUE_CONFIG_FILE = 'phue.conf'

CONF_ALLOW_HUE_GROUPS = "allow_hue_groups"
Expand Down Expand Up @@ -54,6 +56,7 @@ async def async_setup(hass, config):
conf = {}

hass.data[DOMAIN] = {}
hass.data[DATA_CONFIGS] = {}
configured = configured_hosts(hass)

# User has configured bridges
Expand All @@ -66,7 +69,7 @@ async def async_setup(hass, config):
host = bridge_conf[CONF_HOST]

# Store config in hass.data so the config entry can find it
hass.data[DOMAIN][host] = bridge_conf
hass.data[DATA_CONFIGS][host] = bridge_conf

# If configured, the bridge will be set up during config entry phase
if host in configured:
Expand All @@ -91,7 +94,7 @@ async def async_setup(hass, config):
async def async_setup_entry(hass, entry):
"""Set up a bridge from a config entry."""
host = entry.data['host']
config = hass.data[DOMAIN].get(host)
config = hass.data[DATA_CONFIGS].get(host)

if config is None:
allow_unreachable = DEFAULT_ALLOW_UNREACHABLE
Expand All @@ -101,11 +104,11 @@ async def async_setup_entry(hass, entry):
allow_groups = config[CONF_ALLOW_HUE_GROUPS]

bridge = HueBridge(hass, entry, allow_unreachable, allow_groups)
hass.data[DOMAIN][host] = bridge

if not await bridge.async_setup():
return False

hass.data[DOMAIN][host] = bridge
config = bridge.api.config
device_registry = await dr.async_get_registry(hass)
device_registry.async_get_or_create(
Expand Down
4 changes: 2 additions & 2 deletions tests/components/hue/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def test_setup_defined_hosts_known_auth(hass):
assert len(mock_config_entries.flow.mock_calls) == 0

# Config stored for domain.
assert hass.data[hue.DOMAIN] == {
assert hass.data[hue.DATA_CONFIGS] == {
'0.0.0.0': {
hue.CONF_HOST: '0.0.0.0',
hue.CONF_FILENAME: 'bla.conf',
Expand Down Expand Up @@ -73,7 +73,7 @@ async def test_setup_defined_hosts_no_known_auth(hass):
}

# Config stored for domain.
assert hass.data[hue.DOMAIN] == {
assert hass.data[hue.DATA_CONFIGS] == {
'0.0.0.0': {
hue.CONF_HOST: '0.0.0.0',
hue.CONF_FILENAME: 'bla.conf',
Expand Down