diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 3fee1445758..8cf2456c0b4 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -91,7 +91,7 @@ class PlugwiseConfigFlow(ConfigFlow, domain=DOMAIN): self.discovery_info = discovery_info _properties = discovery_info.properties - unique_id = discovery_info.hostname.split(".")[0] + unique_id = discovery_info.hostname.split(".")[0].split("-")[0] if config_entry := await self.async_set_unique_id(unique_id): try: await validate_gw_input( diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 4dbe1d2615f..84d2335b16f 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -36,7 +36,8 @@ TEST_USERNAME2 = "stretch" TEST_DISCOVERY = ZeroconfServiceInfo( host=TEST_HOST, addresses=[TEST_HOST], - hostname=f"{TEST_HOSTNAME}.local.", + # The added `-2` is to simulate mDNS collision + hostname=f"{TEST_HOSTNAME}-2.local.", name="mock_name", port=DEFAULT_PORT, properties={