Fix Konnected pro options (#38848)

This commit is contained in:
Kit Klein authored and GitHub committed 2020-08-17 09:47:21 +02:00
1 parent 49edd91f4e
commit 8d8c1335c5
5 files changed
+56 -41

No files matched your search

+30 -18
View File
@@ -312,7 +312,7 @@ async def test_ssdp_host_update(hass, mock_panel):
"10": "Binary Sensor",
"3": "Digital Sensor",
"7": "Digital Sensor",
"11": "Digital Sensor",
"11": "Binary Sensor",
"4": "Switchable Output",
"out1": "Switchable Output",
"alarm1": "Switchable Output",
@@ -321,11 +321,11 @@ async def test_ssdp_host_update(hass, mock_panel):
{"zone": "2", "type": "door"},
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
{"zone": "10", "type": "door"},
{"zone": "11", "type": "window"},
],
"sensors": [
{"zone": "3", "type": "dht"},
{"zone": "7", "type": "ds18b20", "name": "temper"},
{"zone": "11", "type": "dht"},
],
"switches": [
{"zone": "4"},
@@ -391,11 +391,11 @@ async def test_import_existing_config(hass, mock_panel):
{"zone": "2", "type": "door"},
{"zone": 6, "type": "window", "name": "winder", "inverse": True},
{"zone": "10", "type": "door"},
{"zone": "11", "type": "window"},
],
"sensors": [
{"zone": "3", "type": "dht"},
{"zone": 7, "type": "ds18b20", "name": "temper"},
{"zone": "11", "type": "dht"},
],
"switches": [
{"zone": "4"},
@@ -447,7 +447,7 @@ async def test_import_existing_config(hass, mock_panel):
"10": "Binary Sensor",
"3": "Digital Sensor",
"7": "Digital Sensor",
"11": "Digital Sensor",
"11": "Binary Sensor",
"4": "Switchable Output",
"8": "Switchable Output",
"out1": "Switchable Output",
@@ -460,11 +460,11 @@ async def test_import_existing_config(hass, mock_panel):
{"zone": "2", "type": "door", "inverse": False},
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
{"zone": "10", "type": "door", "inverse": False},
{"zone": "11", "type": "window", "inverse": False},
],
"sensors": [
{"zone": "3", "type": "dht", "poll_interval": 3},
{"zone": "7", "type": "ds18b20", "name": "temper", "poll_interval": 3},
{"zone": "11", "type": "dht", "poll_interval": 3},
],
"switches": [
{"activation": "high", "zone": "4"},
@@ -788,7 +788,12 @@ async def test_option_flow(hass, mock_panel):
# make sure we enforce url format
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={"blink": True, "override_api_host": True, "api_host": "badhosturl"},
user_input={
"discovery": False,
"blink": True,
"override_api_host": True,
"api_host": "badhosturl",
},
)
assert result["type"] == "form"
@@ -796,6 +801,7 @@ async def test_option_flow(hass, mock_panel):
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
"discovery": False,
"blink": True,
"override_api_host": True,
"api_host": "http://overridehost:1111",
@@ -810,6 +816,7 @@ async def test_option_flow(hass, mock_panel):
"6": "Binary Sensor",
"out": "Switchable Output",
},
"discovery": False,
"blink": True,
"api_host": "http://overridehost:1111",
"binary_sensors": [
@@ -889,7 +896,7 @@ async def test_option_flow_pro(hass, mock_panel):
"8": "Switchable Output",
"9": "Disabled",
"10": "Binary Sensor",
"11": "Digital Sensor",
"11": "Binary Sensor",
"12": "Disabled",
"out1": "Switchable Output",
"alarm1": "Switchable Output",
@@ -919,6 +926,13 @@ async def test_option_flow_pro(hass, mock_panel):
result["flow_id"], user_input={"type": "door"}
)
assert result["type"] == "form"
assert result["step_id"] == "options_binary"
# zone 11
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "window"}
)
assert result["type"] == "form"
assert result["step_id"] == "options_digital"
# zone 3
@@ -933,13 +947,6 @@ async def test_option_flow_pro(hass, mock_panel):
result["flow_id"], user_input={"type": "ds18b20", "name": "temper"}
)
assert result["type"] == "form"
assert result["step_id"] == "options_digital"
# zone 11
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "dht"}
)
assert result["type"] == "form"
assert result["step_id"] == "options_switch"
# zone 4
@@ -978,14 +985,15 @@ async def test_option_flow_pro(hass, mock_panel):
assert result["step_id"] == "options_misc"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"blink": True, "override_api_host": False},
result["flow_id"],
user_input={"discovery": False, "blink": True, "override_api_host": False},
)
assert result["type"] == "create_entry"
assert result["data"] == {
"io": {
"10": "Binary Sensor",
"11": "Digital Sensor",
"11": "Binary Sensor",
"2": "Binary Sensor",
"3": "Digital Sensor",
"4": "Switchable Output",
@@ -995,17 +1003,18 @@ async def test_option_flow_pro(hass, mock_panel):
"alarm1": "Switchable Output",
"out1": "Switchable Output",
},
"discovery": False,
"blink": True,
"api_host": "",
"binary_sensors": [
{"zone": "2", "type": "door", "inverse": False},
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
{"zone": "10", "type": "door", "inverse": False},
{"zone": "11", "type": "window", "inverse": False},
],
"sensors": [
{"zone": "3", "type": "dht", "poll_interval": 3},
{"zone": "7", "type": "ds18b20", "name": "temper", "poll_interval": 3},
{"zone": "11", "type": "dht", "poll_interval": 3},
],
"switches": [
{"activation": "high", "zone": "4"},
@@ -1141,14 +1150,17 @@ async def test_option_flow_import(hass, mock_panel):
schema = result["data_schema"]({})
assert schema["blink"] is True
assert schema["discovery"] is True
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"blink": False, "override_api_host": False},
result["flow_id"],
user_input={"discovery": True, "blink": False, "override_api_host": False},
)
# verify the updated fields
assert result["type"] == "create_entry"
assert result["data"] == {
"io": {"1": "Binary Sensor", "2": "Digital Sensor", "3": "Switchable Output"},
"discovery": True,
"blink": False,
"api_host": "",
"binary_sensors": [
+12 -15
View File
@@ -224,9 +224,9 @@ async def test_create_and_setup_pro(hass, mock_panel):
"2": "Binary Sensor",
"6": "Binary Sensor",
"10": "Binary Sensor",
"11": "Binary Sensor",
"3": "Digital Sensor",
"7": "Digital Sensor",
"11": "Digital Sensor",
"4": "Switchable Output",
"8": "Switchable Output",
"out1": "Switchable Output",
@@ -236,11 +236,11 @@ async def test_create_and_setup_pro(hass, mock_panel):
{"zone": "2", "type": "door"},
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
{"zone": "10", "type": "door"},
{"zone": "11", "type": "window"},
],
"sensors": [
{"zone": "3", "type": "dht"},
{"zone": "3", "type": "dht", "poll_interval": 5},
{"zone": "7", "type": "ds18b20", "name": "temper"},
{"zone": "11", "type": "dht", "poll_interval": 5},
],
"switches": [
{"zone": "4"},
@@ -294,17 +294,14 @@ async def test_create_and_setup_pro(hass, mock_panel):
# confirm the settings are sent to the panel
# pylint: disable=no-member
assert mock_panel.put_settings.call_args_list[0][1] == {
"sensors": [{"zone": "2"}, {"zone": "6"}, {"zone": "10"}],
"sensors": [{"zone": "2"}, {"zone": "6"}, {"zone": "10"}, {"zone": "11"}],
"actuators": [
{"trigger": 1, "zone": "4"},
{"trigger": 0, "zone": "8"},
{"trigger": 1, "zone": "out1"},
{"trigger": 1, "zone": "alarm1"},
],
"dht_sensors": [
{"poll_interval": 3, "zone": "3"},
{"poll_interval": 5, "zone": "11"},
],
"dht_sensors": [{"poll_interval": 5, "zone": "3"}],
"ds18b20_sensors": [{"zone": "7"}],
"auth_token": "11223344556677889900",
"blink": True,
@@ -315,6 +312,12 @@ async def test_create_and_setup_pro(hass, mock_panel):
# confirm the device settings are saved in hass.data
assert device.stored_configuration == {
"binary_sensors": {
"11": {
"inverse": False,
"name": "Konnected 445566 Zone 11",
"state": None,
"type": "window",
},
"10": {
"inverse": False,
"name": "Konnected 445566 Zone 10",
@@ -337,17 +340,11 @@ async def test_create_and_setup_pro(hass, mock_panel):
"sensors": [
{
"name": "Konnected 445566 Sensor 3",
"poll_interval": 3,
"poll_interval": 5,
"type": "dht",
"zone": "3",
},
{"name": "temper", "poll_interval": 3, "type": "ds18b20", "zone": "7"},
{
"name": "Konnected 445566 Sensor 11",
"poll_interval": 5,
"type": "dht",
"zone": "11",
},
],
"switches": [
{