Skip to content

Fix entity ID duplication by migrating to has_entity_name - #159

Open
billda wants to merge 1 commit into
schmittx:mainfrom
billda:codex/fix-has-entity-name
Open

Fix entity ID duplication by migrating to has_entity_name#159
billda wants to merge 1 commit into
schmittx:mainfrom
billda:codex/fix-has-entity-name

Conversation

@billda

@billda billda commented Apr 7, 2026

Copy link
Copy Markdown

Summary

This fixes duplicated entity IDs caused by the integration using a legacy entity naming pattern that no longer matches current Home Assistant behavior.

For clients and other non-network resources, the integration was including the resource name in both device_info.name and the entity name. Home Assistant then prepended the device name again when generating the entity ID, which produced IDs such as device_tracker.dad_ssid_dad.

Root Cause

Current versions of Home Assistant generate entity IDs for device-backed entities using the device name plus the entity name.

This integration was still building full entity names manually:

  • device_info.name was set to self.resource.name
  • EeroEntity.name also included self.resource.name
  • has_entity_name = True was not set

That caused the resource/device label to appear twice in the generated entity ID.

Fix

This change migrates EeroEntity to Home Assistant's has_entity_name pattern:

  • sets _attr_has_entity_name = True
  • moves network-prefix and client connection-type formatting into device_info.name
  • changes name to return only the entity-level descriptor from the entity description
  • returns None when the entity description has no name defined, so primary entities use just the device name
  • removes the device_tracker entity name override so tracker IDs now inherit the corrected base behavior

This preserves the existing prefix_network_name and suffix_connection_type options while preventing resource-name duplication in entity IDs.

Expected Behavior After This Change

For a client named dad on a network named ssid:

With prefix_network_name = true:

  • device_tracker.ssid_dad
  • binary_sensor.ssid_dad_connected
  • sensor.ssid_dad_download_rate

With prefix_network_name = false:

  • device_tracker.dad
  • binary_sensor.dad_connected
  • sensor.dad_download_rate

Breaking Change

This changes generated entity IDs for newly created entities.

Users will need to update automations, dashboards, and scripts that reference the old entity IDs. The safest recovery path is to delete and re-add the integration so Home Assistant rebuilds the device and entity registry entries using the corrected naming behavior.

Validation

  • Reviewed all EeroEntity naming branches for clients, eeros, profiles, backup networks, and networks
  • Verified the device_tracker description still has no explicit entity name, so it correctly falls back to the device name only
  • Confirmed no changes to unique_id, config flow options, or API models
  • Ran python3 -m py_compile custom_components/eero/__init__.py custom_components/eero/device_tracker.py

Fixes #158.

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.

Entity IDs contain duplicated device name due to legacy naming + HA device name prepending

1 participant