-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Matter label usage #141113
Fix Matter label usage #141113
Conversation
Hey there @home-assistant/matter, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
if ( | ||
not hasattr(entity_info.entity_description, "ignore_matter_label_name") | ||
or entity_info.entity_description.ignore_matter_label_name is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change are in these lines 64, and 118-120 - if the attribute ignore_matter_label_name is set to True, then don't use FixedLable or UserLable. For backward-compatibility, if the attribute isn't present, the code operates as it previously did.
The rest of the marked changes are due to the way in which github processed the addition/deletion. It looks like a lot of changes, but the remainder of code down below is what was there before - probably flagged due to additional indenting because o the added "if" statement.
@@ -11,7 +11,8 @@ | |||
from matter_server.client.models.node import MatterEndpoint | |||
|
|||
from homeassistant.const import Platform | |||
from homeassistant.helpers.entity import EntityDescription | |||
|
|||
from .entity import MatterEntityDescription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to using MatterEntityDescription instead of EntityDescription so I could access the additional attribute ignore_matter_label_names.
@@ -83,6 +83,7 @@ def _update_from_device(self) -> None: | |||
ha_to_native_value=lambda x: None if x == 255 else int(x), | |||
native_step=1, | |||
native_unit_of_measurement=None, | |||
ignore_matter_label_name=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this attribute now causes the default attribute name to be used, rather than the FixedLabel or UserLabel name.
I realized this weekend there may be another way to address this naming issue. Instead of having an explicit flag to ignore FixedLabel, as I've done here, another approach is to simply ignore "FixedLabel" for any entity type that is EntityCategory.DIAGNOSTIC or EntityCategory.CONFIG. It occurred to me that CONFIG and DIAGNOSTIC entities should not be renamed based on the label. I can redo the PR if reviewers / approvers think that is the better method to address this naming issue. |
I think I have a better way of handling this, so closing for now while I investigate alternate solution. |
Breaking change
Proposed change
This pull request prevents unintended overwriting of Matter attribute names by an endpoint's FixedLabel or UserLabel attribute values.
For Matter devices, attribute values can set through, e.g., number entities added in the number.py schema. For example, the Onlevel, OnTransitionTime, and OffTransition time attributes of the LevelControl cluster are added through number.py. For these entities, it is desirable to always use the name set in strings.py. However, if the endpoint also has a FixedLabel or UserLabel cluster, the intended name for these attributes from string.py will be overwritten by the label with the result that multiple attributes end up having the same name (quite bad from a user interface perspective). This fix allows you to specify in the discovery schema that the FixedLabel or UserLabel label should be ignored by setting ignore_matter_label_name to True.
This fix closes out the issue I previously raised here: #133233
Tagging @marcelveldt here since he helped me add the initial number.py support - I think this is a simple solution to the problem I described, but maybe he has better ideas.
"Real World" devices that have this problem include Inovelli Fan Switch VTM36 and Inovelli's upcoming Matter Switch (VTM30) which I'm beta testing. Samples of these devices can be sent if needed.
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: