Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix deconz allow_clip_sensor and allow_deconz_groups options (#25811)
  • Loading branch information
Anonym-tsk authored and Kane610 committed Aug 9, 2019
1 parent ecddeb2 commit 8b6ddc2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/deconz/gateway.py
Expand Up @@ -63,12 +63,12 @@ def master(self) -> bool:
@property
def allow_clip_sensor(self) -> bool:
"""Allow loading clip sensor from gateway."""
return self.config_entry.data.get(CONF_ALLOW_CLIP_SENSOR, True)
return self.config_entry.options.get(CONF_ALLOW_CLIP_SENSOR, True)

@property
def allow_deconz_groups(self) -> bool:
"""Allow loading deCONZ groups from gateway."""
return self.config_entry.data.get(CONF_ALLOW_DECONZ_GROUPS, True)
return self.config_entry.options.get(CONF_ALLOW_DECONZ_GROUPS, True)

async def async_update_device_registry(self):
"""Update device registry."""
Expand Down
10 changes: 7 additions & 3 deletions tests/components/deconz/test_binary_sensor.py
Expand Up @@ -31,14 +31,17 @@


ENTRY_CONFIG = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
deconz.config_flow.CONF_API_KEY: "ABCDEF",
deconz.config_flow.CONF_BRIDGEID: "0123456789",
deconz.config_flow.CONF_HOST: "1.2.3.4",
deconz.config_flow.CONF_PORT: 80,
}

ENTRY_OPTIONS = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
}


async def setup_gateway(hass, data, allow_clip_sensor=True):
"""Load the deCONZ binary sensor platform."""
Expand All @@ -47,7 +50,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):
loop = Mock()
session = Mock()

ENTRY_CONFIG[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor
ENTRY_OPTIONS[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor

config_entry = config_entries.ConfigEntry(
1,
Expand All @@ -56,6 +59,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):
ENTRY_CONFIG,
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
ENTRY_OPTIONS,
)
gateway = deconz.DeconzGateway(hass, config_entry)
gateway.api = DeconzSession(loop, session, **config_entry.data)
Expand Down
10 changes: 7 additions & 3 deletions tests/components/deconz/test_climate.py
Expand Up @@ -39,14 +39,17 @@
}

ENTRY_CONFIG = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
deconz.config_flow.CONF_API_KEY: "ABCDEF",
deconz.config_flow.CONF_BRIDGEID: "0123456789",
deconz.config_flow.CONF_HOST: "1.2.3.4",
deconz.config_flow.CONF_PORT: 80,
}

ENTRY_OPTIONS = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
}


async def setup_gateway(hass, data, allow_clip_sensor=True):
"""Load the deCONZ sensor platform."""
Expand All @@ -59,7 +62,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):

session = Mock(put=asynctest.CoroutineMock(return_value=response))

ENTRY_CONFIG[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor
ENTRY_OPTIONS[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor

config_entry = config_entries.ConfigEntry(
1,
Expand All @@ -68,6 +71,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):
ENTRY_CONFIG,
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
ENTRY_OPTIONS,
)
gateway = deconz.DeconzGateway(hass, config_entry)
gateway.api = DeconzSession(hass.loop, session, **config_entry.data)
Expand Down
10 changes: 7 additions & 3 deletions tests/components/deconz/test_light.py
Expand Up @@ -62,14 +62,17 @@


ENTRY_CONFIG = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
deconz.config_flow.CONF_API_KEY: "ABCDEF",
deconz.config_flow.CONF_BRIDGEID: "0123456789",
deconz.config_flow.CONF_HOST: "1.2.3.4",
deconz.config_flow.CONF_PORT: 80,
}

ENTRY_OPTIONS = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
}


async def setup_gateway(hass, data, allow_deconz_groups=True):
"""Load the deCONZ light platform."""
Expand All @@ -78,7 +81,7 @@ async def setup_gateway(hass, data, allow_deconz_groups=True):
loop = Mock()
session = Mock()

ENTRY_CONFIG[deconz.const.CONF_ALLOW_DECONZ_GROUPS] = allow_deconz_groups
ENTRY_OPTIONS[deconz.const.CONF_ALLOW_DECONZ_GROUPS] = allow_deconz_groups

config_entry = config_entries.ConfigEntry(
1,
Expand All @@ -87,6 +90,7 @@ async def setup_gateway(hass, data, allow_deconz_groups=True):
ENTRY_CONFIG,
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
ENTRY_OPTIONS,
)
gateway = deconz.DeconzGateway(hass, config_entry)
gateway.api = DeconzSession(loop, session, **config_entry.data)
Expand Down
10 changes: 7 additions & 3 deletions tests/components/deconz/test_sensor.py
Expand Up @@ -75,14 +75,17 @@


ENTRY_CONFIG = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
deconz.config_flow.CONF_API_KEY: "ABCDEF",
deconz.config_flow.CONF_BRIDGEID: "0123456789",
deconz.config_flow.CONF_HOST: "1.2.3.4",
deconz.config_flow.CONF_PORT: 80,
}

ENTRY_OPTIONS = {
deconz.const.CONF_ALLOW_CLIP_SENSOR: True,
deconz.const.CONF_ALLOW_DECONZ_GROUPS: True,
}


async def setup_gateway(hass, data, allow_clip_sensor=True):
"""Load the deCONZ sensor platform."""
Expand All @@ -91,7 +94,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):
loop = Mock()
session = Mock()

ENTRY_CONFIG[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor
ENTRY_OPTIONS[deconz.const.CONF_ALLOW_CLIP_SENSOR] = allow_clip_sensor

config_entry = config_entries.ConfigEntry(
1,
Expand All @@ -100,6 +103,7 @@ async def setup_gateway(hass, data, allow_clip_sensor=True):
ENTRY_CONFIG,
"test",
config_entries.CONN_CLASS_LOCAL_PUSH,
ENTRY_OPTIONS,
)
gateway = deconz.DeconzGateway(hass, config_entry)
gateway.api = DeconzSession(loop, session, **config_entry.data)
Expand Down

0 comments on commit 8b6ddc2

Please sign in to comment.