-
Notifications
You must be signed in to change notification settings - Fork 737
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
Refactor Aqara Roller Driver E1 as v2 quirk to expose configuration and status entities #3686
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 #3686 +/- ##
==========================================
+ Coverage 89.86% 90.53% +0.67%
==========================================
Files 322 324 +2
Lines 10387 10700 +313
==========================================
+ Hits 9334 9687 +353
+ Misses 1053 1013 -40 ☔ View full report in Codecov by Sentry. |
Have identified an issue with the cover state not reliably changing to open/closed. Investigating this currently. |
@TheJulianJES, @dmulcahey looking at the code in https://github.com/zigpy/zha/blob/dev/zha/application/platforms/cover/__init__.py I've tested the following scenarios: 1. go_to_lift_percentage has never been called, down_close is called, then the device reports position_or_tilt of 0 2. go_to_lift_percentage has never been called, up_open is called, then the device reports position_or_tilt of 100 3. go_to_lift_percentage is called (go to 0), then the device reports position_or_tilt of 0 4. go_to_lift_percentage is called (go to 100), then the device reports position_or_tilt of 100 5. go_to_lift_percentage is called (go to 50), then the device reports position_or_tilt of 50 6. go_to_lift_percentage has previously been called (stored value is 50), down_close is called, then the device reports position_or_tilt of 0 7. go_to_lift_percentage has previously been called (stored value is 50), up_open is called, then the device reports position_or_tilt of 100 8. go_to_lift_percentage has previously been called (stored value is 50) and current position is 100, stop is called I'd suggest we can handle this in one of 3 ways:
Below is the current function for reference:
|
I've been working on changes to the ZHA cover entity hander to address the underlying status issue outlined above (it also affects the existing v1 quirk code for this and other devices). I'll raise a bug and PR to address these over the weekend, current WIP code here: |
- Refactor into v2 quirk - Refactor clusters to use AttributeDefs format - Represent the device as a Rollershade rather than Drapery - Refresh current position after a stop command is issued - Expose attributes as entities: - Motor speed (select) - Charging status (binary sensor) - Calibration status (binary sensor) - Reads to current_position_lift_percentage are redirected to AnalogOutput present_value - Writes to AnalogOutput present_value from go_to_lift_percentage commands do not prematurely update the current_position_lift_percentage
6e88fde
to
fb55985
Compare
@TheJulianJES if I'm reading zigpy/zigpy#1540 I believe I should be able to use the proposed If so I'll remove the custom converter I've implemented in this quirk once your PR is merged. |
@TheJulianJES the Right now ZHA exposes this as a separate number entity in addition to the cover entity. When adding custom entities in a v2 quirk we're able to mark them as disabled by default, do you think it would be beneficial to extend this to regular cluster attributes? Critically this would be different to entirely removing the cluster/marking an attribute as unsupported in the cluster, since we'd still want to remap attribute updates/writes from the cover commands to the cluster. |
With zigpy/zigpy#1535, that should be allowed in the future. Do note that the ZHA part wasn't PR'd yet, so it won't do anything for now. |
The AnalogOutput cluster is used to write target position to the device. The present_value reported/read provides the current position/starting position when the device is in motion. Both of these functions are re-mapped into the ZCL WindowCovering cluster, so the number entity created is redundant. This also pre-emptively hides the MultistateOutput cluster, though there is currently no cluster handler implemented for this.
Depends on the following PRs: - zigpy/zigpy#1540 - zigpy/zha#360
Proposed change
This PR refactors the existing Aqara Roller Driver E1 quirk into the new v2 structure to expose the configuration and status attributes, below is a summary of changes:
Functional enhancements
Additional information
Depends on the following PRs for binary_sensor value conversion:
attribute_converter
to quirks v2 sensors zigpy#1540attribute_converter
zha#360Whilst I've validated that is works with my own E1 roller shade devices, I'd like to ensure other users do not encounter any regressions with this refactor.
@dmulcahey / @schwickster / @javicalle / @badrpc / @TheJulianJES I can see in the past you've previously contributed for this device, if you still use it would you mind checking if this updated quirk works as expected without introducing regressions?
Checklist
pre-commit
checks pass / the code has been formatted using Black