diff --git a/homeassistant/components/esphome/config_flow.py b/homeassistant/components/esphome/config_flow.py index 1c23110644b..8011c57ab03 100644 --- a/homeassistant/components/esphome/config_flow.py +++ b/homeassistant/components/esphome/config_flow.py @@ -472,6 +472,9 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN): "host": self._host, "expected_mac": format_mac(self._reconfig_entry.unique_id), } + await self._async_validate_mac_abort_configured( + format_mac(self.unique_id), self._host, self._port + ) for entry in self._async_current_entries(include_ignore=False): if ( entry.entry_id != self._reconfig_entry.entry_id @@ -485,12 +488,7 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN): }, ) if self._reconfig_entry.unique_id != format_mac(self.unique_id): - if ( - self._reconfig_entry.data[CONF_DEVICE_NAME] == self._device_name - and not self.hass.config_entries.async_entry_for_domain_unique_id( - self.handler, format_mac(self.unique_id) - ) - ): + if self._reconfig_entry.data[CONF_DEVICE_NAME] == self._device_name: self._entry_with_name_conflict = self._reconfig_entry return await self.async_step_name_conflict() return self.async_abort( diff --git a/tests/components/esphome/test_config_flow.py b/tests/components/esphome/test_config_flow.py index 01a09be8613..8cac0ea867b 100644 --- a/tests/components/esphome/test_config_flow.py +++ b/tests/components/esphome/test_config_flow.py @@ -1939,7 +1939,7 @@ async def test_reconfig_name_conflict_other_entry_for_mac( ) assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "reconfigure_unique_id_changed" + assert result["reason"] == "already_configured" @pytest.mark.usefixtures("mock_zeroconf", "mock_setup_entry")