Fix duplicate power sensors for Matter 1.3 powerplugs #126269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
We have added support for the new Matter 1.3 ElectricalPower/ElectricalEnergy clusters (for native power measurements on e.g. powerplugs) a few weeks back and added a bit of logic to prevent discovery of the old (custom cluster) attributes.
There was however a small oversight (I now realize with an actual device to test with), which is that the new attributes are not on the same endpoint so the check fails and you have duplicate attributes.
This adds support for "absent_clusters" to the discovery schema where you can give a set of clusters that need to be absent (on all endpoints) before an attribute can be discovered. I adjusted the discovery schemas of the custom attributes.
Tested with an Eve plug updated to 3.5.0 (Matter 1.3) and its now working well. No more duplicate entities.
Only downside is that the user has to cleanup the old orphaned entities but we also marked that as breaking issue in the previous PR.
Updated the test fixture as well.
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: