diff --git a/homeassistant/components/konnected/config_flow.py b/homeassistant/components/konnected/config_flow.py index a6b01560c50..f545c5f2f2a 100644 --- a/homeassistant/components/konnected/config_flow.py +++ b/homeassistant/components/konnected/config_flow.py @@ -185,7 +185,7 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self.data[CONF_PORT] = port try: 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): raise CannotConnect else: @@ -293,7 +293,9 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): except CannotConnect: errors["base"] = "cannot_connect" 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) # save off our discovered host info diff --git a/homeassistant/components/konnected/panel.py b/homeassistant/components/konnected/panel.py index 793a5ee3d21..3b19a700837 100644 --- a/homeassistant/components/konnected/panel.py +++ b/homeassistant/components/konnected/panel.py @@ -76,7 +76,7 @@ class AlarmPanel: @property 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) @property diff --git a/tests/components/konnected/test_config_flow.py b/tests/components/konnected/test_config_flow.py index a0d870b37ff..dbca89efe30 100644 --- a/tests/components/konnected/test_config_flow.py +++ b/tests/components/konnected/test_config_flow.py @@ -69,7 +69,9 @@ async def test_pro_flow_works(hass, mock_panel): assert result["type"] == "form" assert result["step_id"] == "user" + # pro uses chipId instead of MAC as unique id mock_panel.get_status.return_value = { + "chipId": "1234567", "mac": "11:22:33:44:55:66", "model": "Konnected Pro", } @@ -80,7 +82,7 @@ async def test_pro_flow_works(hass, mock_panel): assert result["step_id"] == "confirm" assert result["description_placeholders"] == { "model": "Konnected Alarm Panel Pro", - "id": "112233445566", + "id": "1234567", "host": "1.2.3.4", "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): - """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 = { + "chipId": "somechipid", "mac": "11:22:33:44:55:66", "model": "Konnected Pro", } @@ -224,12 +227,12 @@ async def test_import_ssdp_host_user_finish(hass, mock_panel): "out1": "Disabled", }, }, - "id": "112233445566", + "id": "somechipid", }, ) assert result["type"] == "form" assert result["step_id"] == "import_confirm" - assert result["description_placeholders"]["id"] == "112233445566" + assert result["description_placeholders"]["id"] == "somechipid" # discover the panel via ssdp 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["description_placeholders"] == { "model": "Konnected Alarm Panel Pro", - "id": "112233445566", + "id": "somechipid", "host": "0.0.0.0", "port": 1234, }