mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Use chip id in Konnected pro boards (#36940)
* use chip id in pro boards * cleaner failover
This commit is contained in:
parent
2fd6431cff
commit
a074cf4afd
@ -185,7 +185,7 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self.data[CONF_PORT] = port
|
self.data[CONF_PORT] = port
|
||||||
try:
|
try:
|
||||||
status = await get_status(self.hass, host, port)
|
status = await get_status(self.hass, host, port)
|
||||||
self.data[CONF_ID] = status["mac"].replace(":", "")
|
self.data[CONF_ID] = status.get("chipId", status["mac"].replace(":", ""))
|
||||||
except (CannotConnect, KeyError):
|
except (CannotConnect, KeyError):
|
||||||
raise CannotConnect
|
raise CannotConnect
|
||||||
else:
|
else:
|
||||||
@ -293,7 +293,9 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
self.data[CONF_ID] = status["mac"].replace(":", "")
|
self.data[CONF_ID] = status.get(
|
||||||
|
"chipId", status["mac"].replace(":", "")
|
||||||
|
)
|
||||||
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
||||||
|
|
||||||
# save off our discovered host info
|
# save off our discovered host info
|
||||||
|
@ -76,7 +76,7 @@ class AlarmPanel:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def device_id(self):
|
def device_id(self):
|
||||||
"""Device id is the MAC address as string with punctuation removed."""
|
"""Device id is the chipId (pro) or MAC address as string with punctuation removed."""
|
||||||
return self.config.get(CONF_ID)
|
return self.config.get(CONF_ID)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -69,7 +69,9 @@ async def test_pro_flow_works(hass, mock_panel):
|
|||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
# pro uses chipId instead of MAC as unique id
|
||||||
mock_panel.get_status.return_value = {
|
mock_panel.get_status.return_value = {
|
||||||
|
"chipId": "1234567",
|
||||||
"mac": "11:22:33:44:55:66",
|
"mac": "11:22:33:44:55:66",
|
||||||
"model": "Konnected Pro",
|
"model": "Konnected Pro",
|
||||||
}
|
}
|
||||||
@ -80,7 +82,7 @@ async def test_pro_flow_works(hass, mock_panel):
|
|||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
assert result["description_placeholders"] == {
|
assert result["description_placeholders"] == {
|
||||||
"model": "Konnected Alarm Panel Pro",
|
"model": "Konnected Alarm Panel Pro",
|
||||||
"id": "112233445566",
|
"id": "1234567",
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
"port": 1234,
|
"port": 1234,
|
||||||
}
|
}
|
||||||
@ -192,8 +194,9 @@ async def test_import_no_host_user_finish(hass, mock_panel):
|
|||||||
|
|
||||||
|
|
||||||
async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
||||||
"""Test importing a panel with no host info which ssdp discovers."""
|
"""Test importing a pro panel with no host info which ssdp discovers."""
|
||||||
mock_panel.get_status.return_value = {
|
mock_panel.get_status.return_value = {
|
||||||
|
"chipId": "somechipid",
|
||||||
"mac": "11:22:33:44:55:66",
|
"mac": "11:22:33:44:55:66",
|
||||||
"model": "Konnected Pro",
|
"model": "Konnected Pro",
|
||||||
}
|
}
|
||||||
@ -224,12 +227,12 @@ async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
|||||||
"out1": "Disabled",
|
"out1": "Disabled",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"id": "112233445566",
|
"id": "somechipid",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "import_confirm"
|
assert result["step_id"] == "import_confirm"
|
||||||
assert result["description_placeholders"]["id"] == "112233445566"
|
assert result["description_placeholders"]["id"] == "somechipid"
|
||||||
|
|
||||||
# discover the panel via ssdp
|
# discover the panel via ssdp
|
||||||
ssdp_result = await hass.config_entries.flow.async_init(
|
ssdp_result = await hass.config_entries.flow.async_init(
|
||||||
@ -251,7 +254,7 @@ async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
|||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
assert result["description_placeholders"] == {
|
assert result["description_placeholders"] == {
|
||||||
"model": "Konnected Alarm Panel Pro",
|
"model": "Konnected Alarm Panel Pro",
|
||||||
"id": "112233445566",
|
"id": "somechipid",
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": 1234,
|
"port": 1234,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user