Fix KeyError in device cleanup on Python 3.14 - #169
Open
ColinSummers wants to merge 1 commit into
Open
Conversation
async_remove_device raises KeyError when the device has already been removed from the registry (e.g. by a prior iteration of the cleanup loop). Python 3.14's ReadOnlyDict.pop() surfaces this as an unhandled exception, causing the entire integration setup to fail with setup_error. Wrap the call in try/except to handle the race gracefully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mikesten
added a commit
to mikesten/home-assistant-eero
that referenced
this pull request
Aug 12, 2026
…d code, typos Adopted from ColinSummers via schmittx#171 (unmerged upstream). Carries PR schmittx#169 (Python 3.14 device-cleanup KeyError) and PR schmittx#170 (BaseScannerEntity for HA 2026.7+) in its history. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
device_registry.async_remove_device()in try/except to handleKeyErrorwhen a device has already been removed from the registrysetup_error) on Home Assistant running Python 3.14The crash occurs during device cleanup in
__init__.pyline 349. Theasync_remove_devicecall raisesKeyErrorwhen the device is no longer in the registry — Python 3.14'sReadOnlyDict.pop()surfaces this as an unhandled exception.Fixes #165 (Broken after HA core update)
Testing
Tested on Home Assistant 2026.7.x (Python 3.14.5) running on HA Green (aarch64). After applying the fix, the eero integration sets up successfully and all network/device tracking entities appear.
🤖 Generated with Claude Code