Skip to content
Permalink
Browse files

Fix hue retry crash (#21083)

* Fix Hue retry crash

* Fix hue retry crash

* Fix tests
  • Loading branch information...
balloob committed Feb 15, 2019
1 parent 2de65af commit da672c6593a1374ebf0d0475fcce69ebc719c585
Showing with 8 additions and 5 deletions.
  1. +6 −3 homeassistant/components/hue/__init__.py
  2. +2 −2 tests/components/hue/test_init.py
@@ -28,6 +28,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"
@@ -59,6 +61,7 @@
conf = {}

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

# User has configured bridges
@@ -71,7 +74,7 @@
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:
@@ -96,7 +99,7 @@
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
@@ -106,11 +109,11 @@
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(
@@ -39,7 +39,7 @@
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',
@@ -73,7 +73,7 @@
}

# 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',

0 comments on commit da672c6

Please sign in to comment.
You can’t perform that action at this time.