Hass.io discovery flow deconz (#22623)
* Add Hass.io deCONZ discovery flow * add bridge ID * fix attribute * fix strings * Address comments * Add test * Add only instance / changed maybe later
This commit is contained in:
parent
22d93a74a4
commit
5613e8bb60
5 changed files with 116 additions and 9 deletions
|
@ -265,3 +265,52 @@ async def test_options(hass, aioclient_mock):
|
|||
'allow_clip_sensor': False,
|
||||
'allow_deconz_groups': False
|
||||
}
|
||||
|
||||
|
||||
async def test_hassio_single_instance(hass):
|
||||
"""Test we only allow a single config flow."""
|
||||
MockConfigEntry(domain='deconz', data={
|
||||
'host': '1.2.3.4'
|
||||
}).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
'deconz', context={'source': 'hassio'})
|
||||
assert result['type'] == 'abort'
|
||||
assert result['reason'] == 'one_instance_only'
|
||||
|
||||
|
||||
async def test_hassio_confirm(hass):
|
||||
"""Test we can finish a config flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
'deconz',
|
||||
data={
|
||||
'addon': 'Mock Addon',
|
||||
'host': 'mock-deconz',
|
||||
'port': 8080,
|
||||
'serial': 'aa:bb',
|
||||
'api_key': '1234567890ABCDEF',
|
||||
},
|
||||
context={'source': 'hassio'}
|
||||
)
|
||||
assert result['type'] == 'form'
|
||||
assert result['step_id'] == 'hassio_confirm'
|
||||
assert result['description_placeholders'] == {
|
||||
'addon': 'Mock Addon',
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result['flow_id'], {
|
||||
'allow_clip_sensor': True,
|
||||
'allow_deconz_groups': True,
|
||||
}
|
||||
)
|
||||
|
||||
assert result['type'] == 'create_entry'
|
||||
assert result['result'].data == {
|
||||
'host': 'mock-deconz',
|
||||
'port': 8080,
|
||||
'bridgeid': 'aa:bb',
|
||||
'api_key': '1234567890ABCDEF',
|
||||
'allow_clip_sensor': True,
|
||||
'allow_deconz_groups': True,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue