Skip to content

Prefix area to entity ID#170560

Merged
arturpragacz merged 5 commits into
home-assistant:devfrom
arturpragacz:h/entity_registry/prefix-area-to-entity-id
May 19, 2026
Merged

Prefix area to entity ID#170560
arturpragacz merged 5 commits into
home-assistant:devfrom
arturpragacz:h/entity_registry/prefix-area-to-entity-id

Conversation

@arturpragacz
Copy link
Copy Markdown
Member

Proposed change

Prefix area to entity ID.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_registry imports to avoid a new circular dependency after introducing area_registry usage in entity_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.

Comment thread homeassistant/helpers/entity_registry.py
@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch 2 times, most recently from 7ef2800 to 445fd09 Compare May 19, 2026 01:08
Copilot AI review requested due to automatic review settings May 19, 2026 01:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch from 445fd09 to daea40d Compare May 19, 2026 03:38
Copilot AI review requested due to automatic review settings May 19, 2026 10:09
@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch from daea40d to 4fc7624 Compare May 19, 2026 10:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch from 4fc7624 to 2fad12f Compare May 19, 2026 10:10
Copilot AI review requested due to automatic review settings May 19, 2026 10:27
@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch from 2fad12f to 4201c7f Compare May 19, 2026 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@arturpragacz arturpragacz force-pushed the h/entity_registry/prefix-area-to-entity-id branch from 4201c7f to 799b86e Compare May 19, 2026 10:52
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from an implementation / code quality perspective.

@emontnemery
Copy link
Copy Markdown
Contributor

As discussed on Discord, we should add or update a test to show how entity ID generation is affected by the change.

Copilot AI review requested due to automatic review settings May 19, 2026 18:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@arturpragacz arturpragacz marked this pull request as ready for review May 19, 2026 18:38
@arturpragacz arturpragacz requested a review from a team as a code owner May 19, 2026 18:38
@thecode
Copy link
Copy Markdown
Member

thecode commented May 19, 2026

I hope you realize this is going to trigger again the frustration from users about this change.
I don't understand how it make sense to prefix an area to entity id when the area can be changed by the user.

@andreasbrett
Copy link
Copy Markdown
Contributor

I hope you realize this is going to trigger again the frustration from users about this change. I don't understand how it make sense to prefix an area to entity id when the area can be changed by the user.

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

@arturpragacz arturpragacz merged commit f823ef6 into home-assistant:dev May 19, 2026
43 of 44 checks passed
@arturpragacz arturpragacz deleted the h/entity_registry/prefix-area-to-entity-id branch May 19, 2026 18:53
@raman325
Copy link
Copy Markdown
Contributor

raman325 commented May 19, 2026

IMO this shouldn't have been merged until @thecode's concern was resolved, and I don't consider the comment in response a resolution

@arturpragacz
Copy link
Copy Markdown
Member Author

arturpragacz commented May 19, 2026

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

@raman325
Copy link
Copy Markdown
Contributor

understood but you added many reviewers including @thecode, and the only reason I was notified is because Z-Wave is tagged here as well

@arturpragacz
Copy link
Copy Markdown
Member Author

arturpragacz commented May 19, 2026

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.

@raman325

This comment was marked as spam.

heikkih added a commit to heikkih/homeassistant-core that referenced this pull request May 20, 2026
The continue_job button uses the entity_id with 'workshop_' prefix
instead of just 'mock_title_'.

See home-assistant#170560
flz pushed a commit to flz/home-assistant that referenced this pull request May 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include area in entity ID during first-time generation

6 participants