core icon indicating copy to clipboard operation
core copied to clipboard

Maintain unique Matter entity names

Open jvmahon opened this issue 7 months ago • 2 comments

Breaking change

(no breaking changes)

Proposed change

For Matter devices, the entity.py code makes use of the FixedLabel or UserLabel clusters to apply manufacturer-defined names to entities. This works well for event entities (such as those created for Generic Switch button press entities) as well as control entities, however, in the case of Diagnostic and Config entities, it is common for multiple entities to be created from the same endpoint - if a FixedLabel is on that endpoint, all these entities will end up with the same name.

This problem is shown in the example below in which a FixedLabel is on the endpoint and has the name "OnOffLight". In this case, all of the transition time entities for the Level Change cluster end up renamed as "OnOffLight" and the user has no way of knowing what each is for. Using the label still makes sense for the control entity, but not the CONFIG and DIAGNOSTIC entities. This PR fixes that issue by only using FixedLabel or UserLabel for control or event entities.

As an example, on the Inovelli VTM30 device, this is how the attributes entities look without the fix:

image

As you can see, the attributes all get renamed by the FixedLabel value and a user can't tell them appart

After applying this fix, they now are correct and each entity retains a unique name from strings.py:

image

Type of change

  • [ ] Dependency upgrade
  • [X] 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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • [X] The code change is tested and works locally.
  • [X] Local tests pass. Your PR cannot be merged unless tests pass
  • [X] There is no commented out code in this PR.
  • [X] I have followed the development checklist
  • [ ] I have followed the perfect PR recommendations
  • [X] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

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 link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

jvmahon avatar Apr 06 '25 11:04 jvmahon

Hey there @home-assistant/matter, mind taking a look at this pull request as it has been labeled with an integration (matter) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of matter can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign matter Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Apr 06 '25 11:04 home-assistant[bot]

Moved to draft state as I will be revising code.

jvmahon avatar May 10 '25 18:05 jvmahon

I have another topic quite similar but based on the TagList attribute:

  • https://github.com/home-assistant-libs/python-matter-server/issues/1168

lboue avatar Jun 17 '25 07:06 lboue

Moving from "draft" to "closed" state in favor of revised method in this PR https://github.com/home-assistant/core/pull/145652)

jvmahon avatar Jun 22 '25 11:06 jvmahon