Support old tradfri config format (#16841)
parent
4a4c07ac1b
commit
2b2502c91c
|
@ -95,7 +95,9 @@ class FlowHandler(config_entries.ConfigFlow):
|
|||
|
||||
try:
|
||||
data = await get_gateway_info(
|
||||
self.hass, user_input['host'], user_input['identity'],
|
||||
self.hass, user_input['host'],
|
||||
# Old config format had a fixed identity
|
||||
user_input.get('identity', 'homeassistant'),
|
||||
user_input['key'])
|
||||
|
||||
data[CONF_IMPORT_GROUPS] = user_input[CONF_IMPORT_GROUPS]
|
||||
|
|
|
@ -154,3 +154,34 @@ async def test_import_connection(hass, mock_gateway_info, mock_entry_setup):
|
|||
|
||||
assert len(mock_gateway_info.mock_calls) == 1
|
||||
assert len(mock_entry_setup.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_import_connection_legacy(hass, mock_gateway_info,
|
||||
mock_entry_setup):
|
||||
"""Test a connection via import."""
|
||||
mock_gateway_info.side_effect = \
|
||||
lambda hass, host, identity, key: mock_coro({
|
||||
'host': host,
|
||||
'identity': identity,
|
||||
'key': key,
|
||||
'gateway_id': 'mock-gateway'
|
||||
})
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
'tradfri', context={'source': 'import'}, data={
|
||||
'host': '123.123.123.123',
|
||||
'key': 'mock-key',
|
||||
'import_groups': True
|
||||
})
|
||||
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result['result'].data == {
|
||||
'host': '123.123.123.123',
|
||||
'gateway_id': 'mock-gateway',
|
||||
'identity': 'homeassistant',
|
||||
'key': 'mock-key',
|
||||
'import_groups': True
|
||||
}
|
||||
|
||||
assert len(mock_gateway_info.mock_calls) == 1
|
||||
assert len(mock_entry_setup.mock_calls) == 1
|
||||
|
|
Loading…
Reference in New Issue