Skip to content

Fix KeyError in device cleanup on Python 3.14 - #169

Open
ColinSummers wants to merge 1 commit into
schmittx:mainfrom
ColinSummers:fix/device-removal-keyerror
Open

Fix KeyError in device cleanup on Python 3.14#169
ColinSummers wants to merge 1 commit into
schmittx:mainfrom
ColinSummers:fix/device-removal-keyerror

Conversation

@ColinSummers

@ColinSummers ColinSummers commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • Wrap device_registry.async_remove_device() in try/except to handle KeyError when a device has already been removed from the registry
  • Without this fix, the integration fails to set up (setup_error) on Home Assistant running Python 3.14

The crash occurs during device cleanup in __init__.py line 349. The async_remove_device call raises KeyError when the device is no longer in the registry — Python 3.14's ReadOnlyDict.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

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>
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.

Broken after HA core update

1 participant