Prefix area to entity ID#170560
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates entity ID generation to optionally prefix an entity’s object ID with the associated area name (primarily based on device area during initial creation), and adds test coverage to ensure friendly names are unaffected by area assignment.
Changes:
- Extend entity ID generation to include an area prefix when an applicable area can be resolved.
- Add/adjust helper tests for entity ID regeneration scenarios involving device/entity areas.
- Refactor
area_registryimports to avoid a new circular dependency after introducingarea_registryusage inentity_registry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
homeassistant/helpers/entity_registry.py |
Adds area-aware name construction and threads area_id into entity ID generation paths. |
homeassistant/helpers/area_registry.py |
Moves entity_registry import into async_delete to break a circular import chain. |
tests/helpers/test_entity_registry.py |
Expands regeneration test matrix to cover device-area and entity-area interactions. |
tests/helpers/test_entity.py |
Adds coverage asserting friendly names do not include area. |
7ef2800 to
445fd09
Compare
445fd09 to
daea40d
Compare
daea40d to
4fc7624
Compare
4fc7624 to
2fad12f
Compare
2fad12f to
4201c7f
Compare
4201c7f to
799b86e
Compare
emontnemery
left a comment
There was a problem hiding this comment.
LGTM from an implementation / code quality perspective.
|
As discussed on Discord, we should add or update a test to show how entity ID generation is affected by the change. |
|
I hope you realize this is going to trigger again the frustration from users about this change. |
There will always be haters and lovers. I personally love this as I finally have order again and don't have to have to ceiling_light1, ceiling_light1, ceiling_light2 and so on just because I follow HAs naming convention of not including the area in the friendly name anymore. I really dig that in the UI any if my ceiling lights is just "ceiling light" and there's no other metadata mixed into the name just for the sake of differentiating them. I just don't like that this caused ugly entity IDs based on "what came first". |
|
IMO this shouldn't have been merged until @thecode's concern was resolved, and I don't consider the comment in response a resolution |
|
This is not the right place to make any such comments, this PR implements a task from our official roadmap (which is linked in the PR description). |
|
understood but you added many reviewers including @thecode, and the only reason I was notified is because Z-Wave is tagged here as well |
|
Reviewers were added automatically by GitHub, because of the necessary changes to all the integrations' snapshots. Let's stop this conversation now, as people keep getting unneeded pings, as you've yourself noticed. |
This comment was marked as spam.
This comment was marked as spam.
The continue_job button uses the entity_id with 'workshop_' prefix instead of just 'mock_title_'. See home-assistant#170560
Proposed change
Prefix area to entity ID.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: