Improve error message when ESPHome reconfigure selects an unexpected device (#143608)

This commit is contained in:
J. Nick Koston 2025-04-24 08:44:02 -10:00 committed by GitHub
parent 5afcd3e54e
commit 01e2c3272b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View File

@ -323,7 +323,9 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
):
return
assert conflict_entry.unique_id is not None
if updates:
if self.source == SOURCE_RECONFIGURE:
error = "reconfigure_already_configured"
elif updates:
error = "already_configured_updates"
else:
error = "already_configured_detailed"

View File

@ -4,6 +4,7 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"already_configured_detailed": "A device `{name}`, with MAC address `{mac}` is already configured as `{title}`.",
"already_configured_updates": "A device `{name}`, with MAC address `{mac}` is already configured as `{title}`; the existing configuration will be updated with the validated data.",
"reconfigure_already_configured": "A device `{name}` with MAC address `{mac}` is already configured as `{title}`. Reconfiguration was aborted because the new configuration appears to refer to a different device.",
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
"mdns_missing_mac": "Missing MAC address in mDNS properties.",

View File

@ -2228,7 +2228,7 @@ async def test_reconfig_mac_used_by_other_entry(
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_updates"
assert result["reason"] == "reconfigure_already_configured"
assert result["description_placeholders"] == {
"title": "Mock Title",
"name": "test4",