Disable Hue groups for new setups (#31713)
parent
3df2cb6b78
commit
81b159f424
|
@ -11,22 +11,22 @@ from homeassistant.const import CONF_HOST
|
|||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
|
||||
from .bridge import HueBridge
|
||||
from .const import DOMAIN
|
||||
from .const import (
|
||||
CONF_ALLOW_HUE_GROUPS,
|
||||
CONF_ALLOW_UNREACHABLE,
|
||||
DEFAULT_ALLOW_HUE_GROUPS,
|
||||
DEFAULT_ALLOW_UNREACHABLE,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_BRIDGES = "bridges"
|
||||
|
||||
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"
|
||||
DEFAULT_ALLOW_HUE_GROUPS = True
|
||||
|
||||
BRIDGE_CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
# Validate as IP address and then convert back to a string.
|
||||
|
@ -112,8 +112,10 @@ async def async_setup_entry(
|
|||
config = hass.data[DATA_CONFIGS].get(host)
|
||||
|
||||
if config is None:
|
||||
allow_unreachable = DEFAULT_ALLOW_UNREACHABLE
|
||||
allow_groups = DEFAULT_ALLOW_HUE_GROUPS
|
||||
allow_unreachable = entry.data.get(
|
||||
CONF_ALLOW_UNREACHABLE, DEFAULT_ALLOW_UNREACHABLE
|
||||
)
|
||||
allow_groups = entry.data.get(CONF_ALLOW_HUE_GROUPS, DEFAULT_ALLOW_HUE_GROUPS)
|
||||
else:
|
||||
allow_unreachable = config[CONF_ALLOW_UNREACHABLE]
|
||||
allow_groups = config[CONF_ALLOW_HUE_GROUPS]
|
||||
|
|
|
@ -14,7 +14,11 @@ from homeassistant.const import CONF_HOST
|
|||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .bridge import authenticate_bridge
|
||||
from .const import DOMAIN, LOGGER # pylint: disable=unused-import
|
||||
from .const import ( # pylint: disable=unused-import
|
||||
CONF_ALLOW_HUE_GROUPS,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
)
|
||||
from .errors import AuthenticationRequired, CannotConnect
|
||||
|
||||
HUE_MANUFACTURERURL = "http://www.philips.com"
|
||||
|
@ -125,7 +129,11 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
return self.async_create_entry(
|
||||
title=bridge.config.name,
|
||||
data={"host": bridge.host, "username": bridge.username},
|
||||
data={
|
||||
"host": bridge.host,
|
||||
"username": bridge.username,
|
||||
CONF_ALLOW_HUE_GROUPS: False,
|
||||
},
|
||||
)
|
||||
except AuthenticationRequired:
|
||||
errors["base"] = "register_failed"
|
||||
|
|
|
@ -7,3 +7,9 @@ DOMAIN = "hue"
|
|||
# How long to wait to actually do the refresh after requesting it.
|
||||
# We wait some time so if we control multiple lights, we batch requests.
|
||||
REQUEST_REFRESH_DELAY = 0.3
|
||||
|
||||
CONF_ALLOW_UNREACHABLE = "allow_unreachable"
|
||||
DEFAULT_ALLOW_UNREACHABLE = False
|
||||
|
||||
CONF_ALLOW_HUE_GROUPS = "allow_hue_groups"
|
||||
DEFAULT_ALLOW_HUE_GROUPS = True
|
||||
|
|
|
@ -79,6 +79,7 @@ async def test_flow_works(hass):
|
|||
assert result["data"] == {
|
||||
"host": "1.2.3.4",
|
||||
"username": "home-assistant#test-home",
|
||||
"allow_hue_groups": False,
|
||||
}
|
||||
|
||||
assert len(mock_bridge.initialize.mock_calls) == 1
|
||||
|
@ -440,6 +441,7 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass):
|
|||
assert result["data"] == {
|
||||
"host": "2.2.2.2",
|
||||
"username": "username-abc",
|
||||
"allow_hue_groups": False,
|
||||
}
|
||||
entries = hass.config_entries.async_entries("hue")
|
||||
assert len(entries) == 2
|
||||
|
|
Loading…
Reference in New Issue