Skip to content

Fix device tracker: switch to BaseScannerEntity for HA 2026.7 compatibility - #170

Open
ColinSummers wants to merge 3 commits into
schmittx:mainfrom
ColinSummers:fix/device-tracker-in-zones
Open

Fix device tracker: switch to BaseScannerEntity for HA 2026.7 compatibility#170
ColinSummers wants to merge 3 commits into
schmittx:mainfrom
ColinSummers:fix/device-tracker-in-zones

Conversation

@ColinSummers

Copy link
Copy Markdown

Summary

HA 2026.7 deprecated BaseTrackerEntity and changed zone/person tracking to rely on the in_zones state attribute. The eero device tracker manually defined state and state_attributes without integrating with the new zone system.

This switches EeroDeviceTrackerEntity to inherit from BaseScannerEntity — the intended base class for connection-based (router/scanner) trackers. BaseScannerEntity derives state from the existing is_connected property and handles state_attributes automatically.

The entity already had all the properties BaseScannerEntity expects (is_connected, source_type, ip_address, mac_address, hostname), so this is purely a plumbing change — no behavior difference.

Same fix pattern as mudape/iphonedetect#164.

Related: #167

Changes

  • device_tracker.py: Added BaseScannerEntity to class hierarchy, removed manual state and state_attributes methods, cleaned up unused imports (ATTR_HOST_NAME, ATTR_IP, ATTR_MAC, ATTR_SOURCE_TYPE, STATE_HOME, STATE_NOT_HOME, final, StateType)

Testing

Tested on HA 2026.7.2 (HA Green, aarch64). Device tracker entities correctly report home/not_home, extra_state_attributes (connected_to, connection_type, etc.) still appear, and consider_home grace period works as before.

🤖 Generated with Claude Code

ColinSummers and others added 3 commits July 20, 2026 12:48
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>
Fix KeyError in device cleanup on Python 3.14
HA 2026.7 changed zone/person tracking to rely on the in_zones state
attribute. The old manual state/state_attributes approach doesn't set
in_zones, so zone.home reports 0 persons for router-based trackers.

BaseScannerEntity is the intended base class for connection-based
trackers — it derives state from is_connected and handles in_zones
automatically. The existing is_connected, source_type, ip_address,
mac_address, and hostname properties are exactly what it needs.

Closes #3

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.

1 participant