-
Notifications
You must be signed in to change notification settings - Fork 19
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 flow volume sensor entity for the FlowMeasurement cluster #187
base: dev
Are you sure you want to change the base?
Conversation
@@ -69,6 +69,7 @@ | |||
CLUSTER_HANDLER_PRESSURE, | |||
CLUSTER_HANDLER_SMARTENERGY_METERING, | |||
CLUSTER_HANDLER_SOIL_MOISTURE, | |||
CLUSTER_HANDLER_FLOW_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.
these appear to be otherwise alphabetized
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.
Thanks. Hopefully resolved in latest commit (plus other places I'd not stuck to alphabetical order). I also dropped _MEASUREMENT for consistency with other clusters/sensors (e.g. TemperatureMeasurement is called CLUSTER_HANDLER_TEMPERATURE).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #187 +/- ##
==========================================
+ Coverage 95.89% 96.39% +0.49%
==========================================
Files 61 61
Lines 9404 9402 -2
==========================================
+ Hits 9018 9063 +45
+ Misses 386 339 -47 ☔ View full report in Codecov by Sentry. |
This is great! Is there anything we can do to get this reviewed and merged? |
@benbancroft bumping this... can you make the small tweaks from my comment above? |
Hi @dmulcahey I've not had the time to address this yet unfortunately - had family over this weekend. Question: where would you recommend implementing these checks? Are there other examples of where other clusters do similar I can reference? |
I know illuminance does something like this in the formatter: zha/zha/application/platforms/sensor/__init__.py Lines 760 to 766 in c99237f
|
Hi @dmulcahey Thanks! I've gone ahead and implemented the 0xffff unknown state in the same way via a formatter. Regarding MinMeasuredValue and MaxMeasuredValue - I've left this as is for now as this looks like a wider issue throughout most other sensors within ZHA (e.g. Temperature Measurement cluster). I guess strictly speaking, we can largely place trust in the server that it is implementing these constraints for the measured values it reports. The only real use on the client side is enforcing this relationship, or utilising min/max for display of data (e.g. rendering a sliding display). For the latter, as this sensor is exported as a numerical to Home Assistant, it doesn't apply here. Please let me know your thoughts/suggestions here. |
Can someone review and merge this if it looks OK? 🙏 |
Proposed change
Adds a new "volume flow rate" sensor for discovered FlowMeasurement clusters. This is required for the Sonoff SWV-BSP Smart Water Valve, but likely other devices with FlowMeasurement being a standardised Zigbee cluster.
Raw value of "measured_value" is 10 * flow_rate, as per Zigbee cluster specification for FlowMeasurement.
This feature was requested as part of zigpy/zha-device-handlers#3298
Testing
I have tested this with my Sonoff SWV-BSP Smart Water Valve and the sensor is appearing and being exported to Home Assistant no issues with a sane value that matches the flow of water. I have not tested this with any other device that implements FlowMeasurement cluster, but I assume it should work fine.