Skip to content

Fix reauthentication when vacuum host changes#754

Open
AStotal wants to merge 1 commit into
PiotrMachowski:dev_extracted_librariesfrom
AStotal:codex/fix-xiaomi-reauth-entry
Open

Fix reauthentication when vacuum host changes#754
AStotal wants to merge 1 commit into
PiotrMachowski:dev_extracted_librariesfrom
AStotal:codex/fix-xiaomi-reauth-entry

Conversation

@AStotal

@AStotal AStotal commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • select the config entry being reauthenticated from the flow context instead of matching it by host
  • update the entry unique ID when the cloud returns the vacuum's real MAC address
  • add a regression test for reauthentication after the host changes

Root cause

The confirmation step searched existing config entries using the newly submitted host. During reauthentication that host can differ from the stored value, especially when an entry contains a placeholder or the vacuum received a new IP address. The lookup then returned None, but the reauthentication branch still dereferenced existing_entry.data, causing an AttributeError that Home Assistant displayed as an unknown error.

Impact

Reauthentication now updates the intended config entry even when its stored host no longer matches. It also replaces a placeholder or outdated unique ID with the MAC address returned by Xiaomi Cloud.

Validation

  • regression test reproduced the original AttributeError before the fix and passes after it
  • test run against Home Assistant 2026.4.1 on Python 3.14
  • compileall and git diff --check
  • end-to-end reauthentication with a changed host and placeholder MAC completed successfully; the map loaded and no config-flow error remained in the logs

@AStotal
AStotal marked this pull request as ready for review July 14, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant