From 52edf9ac356029438dee0741a5ba9d419decd590 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 13 May 2021 12:35:24 -0500 Subject: [PATCH] Ensure isy994 is only discovered once (#50577) The formatting of the mac was different between dhcp and ssdp --- homeassistant/components/isy994/config_flow.py | 5 ++++- tests/components/isy994/test_config_flow.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/isy994/config_flow.py b/homeassistant/components/isy994/config_flow.py index 502008ff0ab..248d2d9c520 100644 --- a/homeassistant/components/isy994/config_flow.py +++ b/homeassistant/components/isy994/config_flow.py @@ -155,7 +155,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): friendly_name = discovery_info[HOSTNAME] url = f"http://{discovery_info[IP_ADDRESS]}" mac = discovery_info[MAC_ADDRESS] - await self.async_set_unique_id(mac) + isy_mac = ( + f"{mac[0:2]}:{mac[2:4]}:{mac[4:6]}:{mac[6:8]}:{mac[8:10]}:{mac[10:12]}" + ) + await self.async_set_unique_id(isy_mac) self._abort_if_unique_id_configured() self.discovered_conf = { diff --git a/tests/components/isy994/test_config_flow.py b/tests/components/isy994/test_config_flow.py index bf08e6526ba..51750d42718 100644 --- a/tests/components/isy994/test_config_flow.py +++ b/tests/components/isy994/test_config_flow.py @@ -61,7 +61,8 @@ MOCK_IMPORT_FULL_CONFIG = { } MOCK_DEVICE_NAME = "Name of the device" -MOCK_UUID = "CE:FB:72:31:B7:B9" +MOCK_UUID = "ce:fb:72:31:b7:b9" +MOCK_MAC = "cefb7231b7b9" MOCK_VALIDATED_RESPONSE = {"name": MOCK_DEVICE_NAME, "uuid": MOCK_UUID} PATCH_CONFIGURATION = "homeassistant.components.isy994.config_flow.Configuration" @@ -331,7 +332,7 @@ async def test_form_dhcp(hass: HomeAssistant): data={ dhcp.IP_ADDRESS: "1.2.3.4", dhcp.HOSTNAME: "isy994-ems", - dhcp.MAC_ADDRESS: MOCK_UUID, + dhcp.MAC_ADDRESS: MOCK_MAC, }, ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM