-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add AnalogInput, MultistateInput, use description attribute for fallback_name #197
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #197 +/- ##
==========================================
+ Coverage 96.27% 96.29% +0.02%
==========================================
Files 61 61
Lines 9366 9476 +110
==========================================
+ Hits 9017 9125 +108
- Misses 349 351 +2 ☔ View full report in Codecov by Sentry. |
I wonder: would it be feasible to instead set the translation key to the ZCL |
That was the approach I started with, unfortunately, when the translation key wasn't found, it would return None for the name and id. I understood it should then fallback, but that's not the result I observed in testing. |
super().__init__(unique_id, cluster_handlers, endpoint, device, **kwargs) | ||
engineering_units = self._cluster_handler.engineering_units | ||
self._attr_native_unit_of_measurement = UNITS.get(engineering_units) | ||
self._attr_state_class = SensorStateClass.MEASUREMENT |
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.
Should this always be measurement? I can see a situation where total or total increasing makes sense, but I don't see a good way to choose based on the attributes we have available.
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.
There are some restrictions on what we can provide as a translation_key
to Home Assistant. AFAIK, we are not allowed to provide translation keys blindly, so not directly from the description
attribute, for example.
We'd need to map all known description
attribute values to translation keys (and fall-back to a default or untranslated name otherwise).
So, I'm wondering if it would make sense to split this PR into two: one with the translation key changes and one with the added AnalogInput
and MultistateInput
sensors.
We aren't modifying the As far as splitting the PR, it was originally planned to have multiple PRs, one for the |
This will need a zigpy release before tests will pass. |
a76bb19
to
7f12961
Compare
8fd863b
to
bd34bfd
Compare
I think we should update the test json files... that's a lot to delete. Also, should we start these off as disabled by default? |
This ensures that the description attribute (0x001C), if present, is used for the fallback_name and sets the translation_key to None. The entity id and name will use the fallback_name and align with the devices value. This is mostly useful for devices using general clusters, if not set, the current functionality is maintained.
Due to testing requirements, this now also updates the cluster handlers for AnalogInput, MultistateInput, and BinaryInput.
Closes: #160
Multistate still requires zigpy/zigpy#1456 to be fully implemented, since the LVLists aren't serialized, we create a default value for now.
AnalogOutput is putting the description in the name twice.
This is due to this logic in core, should we add similar logic to core for the rest of the Entities and remove it from ZHA, keep the logic in ZHA, or have it mixed?
https://github.com/home-assistant/core/blob/f1e4229b23ef7837bb4e46877f55d6533f8d4607/homeassistant/components/zha/number.py#L52C9-L52C58