Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing or incorrect device name and unique id for ESPHome during manual add #95678

Merged
merged 11 commits into from
Jul 2, 2023
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
bdraco committed Jul 1, 2023
commit c268279c5e9cf2e19113b87f6b737ca5d278a516
5 changes: 2 additions & 3 deletions homeassistant/components/esphome/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ async def fetch_device_info(self) -> str | None:

self._name = self._device_info.friendly_name or self._device_info.name
self._device_name = self._device_info.name
await self.async_set_unique_id(
self._device_info.mac_address, raise_on_progress=False
)
mac_address = format_mac(self._device_info.mac_address)
await self.async_set_unique_id(mac_address, raise_on_progress=False)
if not self._reauth_entry:
self._abort_if_unique_id_configured(
updates={CONF_HOST: self._host, CONF_PORT: self._port}
Expand Down
8 changes: 4 additions & 4 deletions tests/components/esphome/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ async def test_user_dashboard_has_wrong_key(
DeviceInfo(
uses_password=False,
name="test",
mac_address="11:22:33:44:55:aa",
mac_address="11:22:33:44:55:AA",
),
]

Expand Down Expand Up @@ -380,7 +380,7 @@ async def test_user_discovers_name_and_gets_key_from_dashboard(
DeviceInfo(
uses_password=False,
name="test",
mac_address="11:22:33:44:55:aa",
mac_address="11:22:33:44:55:AA",
),
]

Expand Down Expand Up @@ -483,7 +483,7 @@ async def test_user_discovers_name_and_dashboard_is_unavailable(
DeviceInfo(
uses_password=False,
name="test",
mac_address="11:22:33:44:55:aa",
mac_address="11:22:33:44:55:AA",
),
]

Expand Down Expand Up @@ -1201,7 +1201,7 @@ async def test_zeroconf_encryption_key_via_dashboard(
DeviceInfo(
uses_password=False,
name="test8266",
mac_address="11:22:33:44:55:aa",
mac_address="11:22:33:44:55:AA",
),
]

Expand Down