-
Notifications
You must be signed in to change notification settings - Fork 40
Ignore "non-value" attribute values for sensors #414
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #414 +/- ##
=======================================
Coverage 96.70% 96.70%
=======================================
Files 61 61
Lines 9863 9874 +11
=======================================
+ Hits 9538 9549 +11
Misses 325 325 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Since this is a draft, can I use this to patch my local instance and test it, or do you consider it work in progress? |
Sure! I haven't written unit tests for it but have tested it at runtime with a device. |
I just tested this with my own custom zigbee device, and I can confirm that this fixes the issue completely! Thank you very much @puddly ! And the sensor correctly reports as "Unknown" while we send the unknown value :D This is how the mock sensor values look like (it cycles between two modes, first stepdown from 20° -> -20°, then an unknown value for the same time): |
Thanks for the confirmation! |
4d9b897
to
610923f
Compare
@@ -173,6 +174,13 @@ def __init__( | |||
) -> None: | |||
"""Init this sensor.""" | |||
self._cluster_handler: ClusterHandler = cluster_handlers[0] | |||
self._attr_def: foundation.ZCLAttributeDef | None = None | |||
|
|||
if self._attribute_name is not None: |
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.
If you wanted to, could use if (attr := self._attribute_name) is not None:
to just access attr
for the name below, but this is obviously also fine.
Zigpy currently provides a way to determine if a value is a "non-value" for a type. This is easily supported for numeric types but not so much for more complex ones, like arrays and such. This PR will globally fix invalid sensor readings showing up in the frontend.
home-assistant/core#96894