Fix zwave_js default emulate hardware in options flow (#78024)

This commit is contained in:
Martin Hjelmare 2022-09-08 10:59:40 +02:00 committed by GitHub
parent 11e897a5e8
commit bfe245cc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View File

@ -792,7 +792,9 @@ class OptionsFlowHandler(BaseZwaveJSFlow, config_entries.OptionsFlow):
CONF_ADDON_S2_AUTHENTICATED_KEY: self.s2_authenticated_key,
CONF_ADDON_S2_UNAUTHENTICATED_KEY: self.s2_unauthenticated_key,
CONF_ADDON_LOG_LEVEL: user_input[CONF_LOG_LEVEL],
CONF_ADDON_EMULATE_HARDWARE: user_input[CONF_EMULATE_HARDWARE],
CONF_ADDON_EMULATE_HARDWARE: user_input.get(
CONF_EMULATE_HARDWARE, False
),
}
if new_addon_config != addon_config:

View File

@ -1951,6 +1951,30 @@ async def different_device_server_version(*args):
0,
different_device_server_version,
),
(
{"config": ADDON_DISCOVERY_INFO},
{},
{
"device": "/test",
"network_key": "old123",
"s0_legacy_key": "old123",
"s2_access_control_key": "old456",
"s2_authenticated_key": "old789",
"s2_unauthenticated_key": "old987",
"log_level": "info",
},
{
"usb_path": "/new",
"s0_legacy_key": "new123",
"s2_access_control_key": "new456",
"s2_authenticated_key": "new789",
"s2_unauthenticated_key": "new987",
"log_level": "info",
"emulate_hardware": False,
},
0,
different_device_server_version,
),
],
)
async def test_options_different_device(
@ -2018,14 +2042,16 @@ async def test_options_different_device(
result = await hass.config_entries.options.async_configure(result["flow_id"])
await hass.async_block_till_done()
# Default emulate_hardware is False.
addon_options = {"emulate_hardware": False} | old_addon_options
# Legacy network key is not reset.
old_addon_options.pop("network_key")
addon_options.pop("network_key")
assert set_addon_options.call_count == 2
assert set_addon_options.call_args == call(
hass,
"core_zwave_js",
{"options": old_addon_options},
{"options": addon_options},
)
assert result["type"] == "progress"
assert result["step_id"] == "start_addon"