Deconz make groups configurable (#14704)
* Make groups configurable * Config flow and tests in place * Fix too long line
This commit is contained in:
1 parent
940577e105
commit
ac13a2736b
7 files changed
+46
-12
No files matched your search
@@ -23,7 +23,7 @@ async def test_flow_works(hass, aioclient_mock):
|
||||
await flow.async_step_init()
|
||||
await flow.async_step_link(user_input={})
|
||||
result = await flow.async_step_options(
|
||||
user_input={'allow_clip_sensor': True})
|
||||
user_input={'allow_clip_sensor': True, 'allow_deconz_groups': True})
|
||||
|
||||
assert result['type'] == 'create_entry'
|
||||
assert result['title'] == 'deCONZ-id'
|
||||
@@ -32,7 +32,8 @@ async def test_flow_works(hass, aioclient_mock):
|
||||
'host': '1.2.3.4',
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF',
|
||||
'allow_clip_sensor': True
|
||||
'allow_clip_sensor': True,
|
||||
'allow_deconz_groups': True
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +150,7 @@ async def test_bridge_discovery_config_file(hass):
|
||||
'port': 80,
|
||||
'serial': 'id'
|
||||
})
|
||||
|
||||
assert result['type'] == 'create_entry'
|
||||
assert result['title'] == 'deCONZ-id'
|
||||
assert result['data'] == {
|
||||
@@ -156,7 +158,8 @@ async def test_bridge_discovery_config_file(hass):
|
||||
'host': '1.2.3.4',
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF',
|
||||
'allow_clip_sensor': True
|
||||
'allow_clip_sensor': True,
|
||||
'allow_deconz_groups': True
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +220,7 @@ async def test_import_with_api_key(hass):
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF'
|
||||
})
|
||||
|
||||
assert result['type'] == 'create_entry'
|
||||
assert result['title'] == 'deCONZ-id'
|
||||
assert result['data'] == {
|
||||
@@ -224,7 +228,8 @@ async def test_import_with_api_key(hass):
|
||||
'host': '1.2.3.4',
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF',
|
||||
'allow_clip_sensor': True
|
||||
'allow_clip_sensor': True,
|
||||
'allow_deconz_groups': True
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +243,7 @@ async def test_options(hass, aioclient_mock):
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF'}
|
||||
result = await flow.async_step_options(
|
||||
user_input={'allow_clip_sensor': False})
|
||||
user_input={'allow_clip_sensor': False, 'allow_deconz_groups': False})
|
||||
assert result['type'] == 'create_entry'
|
||||
assert result['title'] == 'deCONZ-id'
|
||||
assert result['data'] == {
|
||||
@@ -246,5 +251,6 @@ async def test_options(hass, aioclient_mock):
|
||||
'host': '1.2.3.4',
|
||||
'port': 80,
|
||||
'api_key': '1234567890ABCDEF',
|
||||
'allow_clip_sensor': False
|
||||
'allow_clip_sensor': False,
|
||||
'allow_deconz_groups': False
|
||||
}
|
||||
@@ -38,7 +38,7 @@ GROUP = {
|
||||
}
|
||||
|
||||
|
||||
async def setup_bridge(hass, data):
|
||||
async def setup_bridge(hass, data, allow_deconz_groups=True):
|
||||
"""Load the deCONZ light platform."""
|
||||
from pydeconz import DeconzSession
|
||||
loop = Mock()
|
||||
@@ -53,7 +53,9 @@ async def setup_bridge(hass, data):
|
||||
hass.data[deconz.DATA_DECONZ_UNSUB] = []
|
||||
hass.data[deconz.DATA_DECONZ_ID] = {}
|
||||
config_entry = config_entries.ConfigEntry(
|
||||
1, deconz.DOMAIN, 'Mock Title', {'host': 'mock-host'}, 'test')
|
||||
1, deconz.DOMAIN, 'Mock Title',
|
||||
{'host': 'mock-host', 'allow_deconz_groups': allow_deconz_groups},
|
||||
'test')
|
||||
await hass.config_entries.async_forward_entry_setup(config_entry, 'light')
|
||||
# To flush out the service call to update the group
|
||||
await hass.async_block_till_done()
|
||||
@@ -98,3 +100,15 @@ async def test_add_new_group(hass):
|
||||
async_dispatcher_send(hass, 'deconz_new_group', [group])
|
||||
await hass.async_block_till_done()
|
||||
assert "light.name" in hass.data[deconz.DATA_DECONZ_ID]
|
||||
|
||||
|
||||
async def test_do_not_add_deconz_groups(hass):
|
||||
"""Test that clip sensors can be ignored."""
|
||||
data = {}
|
||||
await setup_bridge(hass, data, allow_deconz_groups=False)
|
||||
group = Mock()
|
||||
group.name = 'name'
|
||||
group.register_async_callback = Mock()
|
||||
async_dispatcher_send(hass, 'deconz_new_group', [group])
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.data[deconz.DATA_DECONZ_ID]) == 0
|
||||
Reference in new issue
Block a user