-
Notifications
You must be signed in to change notification settings - Fork 712
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 Xiaomi E1 driver curtain support #2629
Add Xiaomi E1 driver curtain support #2629
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2629 +/- ##
==========================================
+ Coverage 86.62% 86.68% +0.06%
==========================================
Files 279 280 +1
Lines 8551 8595 +44
==========================================
+ Hits 7407 7451 +44
Misses 1144 1144
☔ View full report in Codecov by Sentry. |
The quirk file can be downloaded from here: https://raw.githubusercontent.com/TheJulianJES/zha-device-handlers/tjj/xiaomi_driver_curtain_e1_new/zhaquirks/xiaomi/aqara/driver_curtain_e1.py Please test what works and what doesn't work. If it shows up as a mains-powered device, you can comment in the If you can, please also look at the TODOs and see if you can answer any of them. I'm not sure how the "motor reversing" works with this device (or how it should work). |
It would also be ideal if we can get some debug logs of the device. Especially, when it's reporting a |
@cannondale0815 and @Nafania, you mentioned you can help test the quirk. There are instructions in this above comment for downloading the new version. Make sure to remove the older custom quirk. Please test what works and what doesn't work (open/close, percentage, stop). Also, if you can enable ZHA debug logs and press a button on the device/or wait until you get a Please also let me know if reversing this motor works correctly now (and when it's needed). |
@TheJulianJES thanks a lot for your work! But i'm not sure how to apply a custom quirk)
and put your file into this dir, restarted HA and now I see on my device card
but I don't know hot to understand which exact quirk is used now. At the device card I can't see any changes. |
Hi @TheJulianJES, My results are the following: Before adding the quirk, it only worked with the percentage slider, but it worked as expected, battery and light sensors weren't shown at all. With the quirk and uncommenting the sensor, a battery, with the status of Unknown shows up and the open and close cover buttons work as well, however with the percentage slider, when I set it to other than 0 or 100% it stays in "Opening" or "Closing" state until I press the stop button. EDIT: The battery also shows as a CR2032 and the power source says "Power source: Battery or Unknown" EDIT 2: Sorry, I was wrong. It gets stuck on Opening or Closing state even without your quirk and the open and close button work strangely without your quirk. Without your quirk, if the open or close button are pressed, while the curtain is fully open or closed, or it is stopped (so not bugged in the Opening or Closing state), than it does nothing. However if it is in Closing state, the open button is pressable, and if pressed, it opens the curtains. Same for the other scenario. |
home-assistant_zha_2023-10-11T14-11-04.960Z.log |
@Nafania The "quirk" section doesn't mention "zhaquirks". It's
That might be expected(?) You should see a cover entity (with and without quirk). The issue was that the cover entity had non-functioning up/down commands for some (depending on firmware). The quirk should fix the up/down commands. This is what needs to be tested (and if "everything works" now). |
I believe this is an issue with ZHA at the moment. I don't have any covers to test with, so I can't fix that at the moment.
Hmm, it seems like only some firmware versions are affected by this then.
Can you state what you mean with "uncommenting the sensor"? You mean you uncommented the
Hmm, I did not know this curtain has one. I'm not sure I'll get around to adding it in this PR, but I'll try to have a look soon into how it's implemented.
This is an issue with ZHA I guess. You can also write that attribute using that page manually. (Change the upper field after reading, leave lower field empty, then press write.) This is the most important question: |
Added some more changes now: https://raw.githubusercontent.com/TheJulianJES/zha-device-handlers/0541ecf7010d2c9b8f8fcd2784c14beb88bcc419/zhaquirks/xiaomi/aqara/driver_curtain_e1.py Please check if the "inverted mode" works correctly. After you did this initial read, you can also restart Home Assistant, and you'll get the configuration entity. So, with this updated quirk version, let me know what works and what doesn't work. |
Hi @TheJulianJES,
Yes, I meant uncommenting the NODE_DESCRIPTOR
I did this. It was by default in inverted mode (returned 1) and the selectable dropdown menu appeared. Now I can set the mode. It seems like after this change, the sider started to do the exact opposite of what I wanted when in inverted mode. With the updated quirk it seems like the controls work perfectly as far as I can see. Now I'll do a test without the quirk: Without the quirk the light sensor is unavailable . Is this enough info, or do you need something else as well? |
Hello @TheJulianJES |
@dominikremes (Only the issue with the configuration entity not appearing at first needs to be fixed in ZHA.) |
@TheJulianJES |
Yeah, the light sensor reports values of 0, 1, 2 only apparently. |
There are multiple issues / pull requests raised on here (#1648, #2003, #2620 & #2629) but thought it may be worthwhile to clarify a few things all in one post. Originally I am using the latest HA (2023.10.x / zhaquirks.xiaomi.aqara.roller_curtain_e1.RollerE1AQ_3) and using the out-of-the-box firmware on the Aqara roller. I am using Skyconnect - everything is latest version. This worked okay - briefly - including in HA. I am able to use both the number and the up / down buttons with corect motion, but the motor couldn't always pull up physically. Battery also appeared to be okay (after a charge), same for device temperature (most of the time) but saw some spikes up to 60+ degrees (despite that the device did not feel warm). Identify, LQI and RSSI all showing. No mention of the light sensor anywhere. Read somewhere online that the issue with pulling up could be due to the outdated firmware. Updated the roller to latest firmware using Aqara Hub E1. Still no mention of the light sensor; however, now facing the issue that the roller was now inverting the up / down when used in ZHA. So, I am trying to test with your changes https://raw.githubusercontent.com/TheJulianJES/zha-device-handlers/tjj/xiaomi_driver_curtain_e1_new/zhaquirks/xiaomi/aqara/driver_curtain_e1.py but despite my trying cannot seem to get the new quirk to show, even after re-pairing. configuration.yaml looks like:
Meanwhile log simply makes mention that it loaded the quirks folder but it did not. Anyway, to fix the the inversion issue (without using any quirks), you simply press the reset button 3 times on the roller itself to change the direction. You will see the LED blink blue to indicate it's changed then job done. Problem solved :) ... Still haven't got the light sensor working though. |
Anyone? Happy to do the testing and maybe a few tweaks here and there but need your help to get started. |
@codyc1515 You have the roller Aqara curtain then I have PR to clean up the code slightly for your device: #2620 Can you open another issue mentioning the issues (with updated firmware) again and tag me there (@TheJulianJES)? |
Apparently this is already done by the cover when "inverted mode" is enabled. Does this depend on firmware?
Possible values are 0, 1, 2 apparently
Doesn't seem to be the case, but I'm not sure.
… main Xiaomi file They'll also be used by other devices (in future PRs)
This functionality was removed, as it seems to be wrong according to comments in zigpy#2629
e087463
to
20fc531
Compare
class XiaomiPowerConfigurationPercent(XiaomiPowerConfiguration): | ||
"""Power cluster which ignores Xiaomi voltage reports for calculating battery percentage | ||
Devices that use this cluster (E1 curtain driver/roller) already send the battery percentage on their own | ||
as a separate attribute, but additionally also send the battery voltage. | ||
This class only uses the voltage reports for the voltage attribute, but not for the battery percentage. | ||
The battery percentage is used as is from the battery percentage reports using inherited battery_percent_reported(). | ||
""" | ||
|
||
def _update_battery_percentage(self, voltage_mv: int) -> None: | ||
"""Ignore Xiaomi voltage reports, so they're not used to calculate battery percentage.""" | ||
# This device sends battery percentage reports which are handled using a XiaomiCluster and | ||
# the inherited XiaomiPowerConfiguration cluster. | ||
# This device might also send Xiaomi battery reports, so we only want to use those for the voltage attribute, | ||
# but not for the battery percentage. XiaomiPowerConfiguration.battery_reported() still updates the voltage. | ||
|
||
|
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.
Note for reviews:
- Clean up Aqara Roller Curtain E1 quirk, add tests #2620 will be updated to use this class as well, hence it's now in the main Xiaomi file.
class LocalIlluminanceMeasurementCluster( | ||
LocalDataCluster, IlluminanceMeasurementCluster | ||
): | ||
"""Illuminance measurement cluster based on LocalDataCluster.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Init.""" | ||
super().__init__(*args, **kwargs) | ||
if self.AttributeDefs.measured_value.id not in self._attr_cache: | ||
# put a default value so the sensor is created | ||
self._update_attribute(self.AttributeDefs.measured_value.id, 0) |
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.
Note for reviews:
- This was copied from the
motion_ac02
(Aqara P1 motion sensor) quirk. - A future PR will change that P1 sensor to use this "main" class.
(similar to the aboveXiaomiPowerConfigurationPercent
class)
Merging now to move forward with multiple other PRs. IMO, the code is fine now and tested (by people and unit tests). Due to the changes, this is the latest commit that still works when only using it as a custom quirk: https://raw.githubusercontent.com/TheJulianJES/zha-device-handlers/0541ecf7010d2c9b8f8fcd2784c14beb88bcc419/zhaquirks/xiaomi/aqara/driver_curtain_e1.py |
Update quirk to the latest version from https://raw.githubusercontent.com/TheJulianJES/zha-device-handlers/0541ecf7010d2c9b8f8fcd2784c14beb88bcc419/zhaquirks/xiaomi/aqara/driver_curtain_e1.py . Just a few comments from my side
@TheJulianJES thanks a lot for your efforts! |
Am having 2 of these devices. I can operate them with some bugs. I can live with both. However, the most annoying problem I have is that both curtains report wrong state!! I would be really grateful if anyone can help me solve this problem |
I'm using the Chinese version of the agl001, the acn003 (see screenshot). I've attempted this quirk, replacing the It has solved the issue of the open / close buttons not working, and by extension the service call to open and close the cover(s), however no battery status and no inversion options. To be honest I don't know enough about writing python or quirks to be able to offer any suggestion, if you're willing to take a look into this please let me know what other info I can share. |
@BackedUpBooty have you added
to configuration.yml file? Do you see a message in the log smth like "custom quirks loaded" during startup to ensure that custom quirks were loaded? |
@Nafania thanks for the reply. you can see in my screenshot under Device info that the quirk is used, my configuration.yml has
and yes the load confirmation message is in the logs. |
@BackedUpBooty It looks like there isn't an issue for that device yet, can you create one (and fill-out the issue template)? |
@TheJulianJES done, #2860 |
* Add quirk for Xiaomi E1 driver curtain * Add tests for Xiaomi E1 driver curtain * Fix inverted logic * Add test for inverted logic * Comment out inverting percentage Apparently this is already done by the cover when "inverted mode" is enabled. Does this depend on firmware? * Add more custom attributes * Add illuminance measurement Possible values are 0, 1, 2 apparently * Add custom node descriptor for disabling "is mains powered" * Move imports * Comment out test for reverting lift percentage We're not inverting it ourselves at the moment * Make illuminance cluster a `LocalDataCluster` * Remove "TODO: `XiaomiAqaraDriverE1` in OUTPUT clusters?" Doesn't seem to be the case, but I'm not sure. * Remove commented code about inverting "go to lift percent" command * Remove commented code about inverting current lift percent attribute * Remove TODO for up/down commands * Change "attributes copy" to copy from `XiaomiAqaraE1Cluster` class * Move local illuminance cluster and custom PowerConfiguration class to main Xiaomi file They'll also be used by other devices (in future PRs) * Remove commented test about testing inverted percent attribute This functionality was removed, as it seems to be wrong according to comments in zigpy#2629 * Change comment for `WindowCoveringE1` cluster class * Add tests for custom light level attribute
* Add quirk for Xiaomi E1 driver curtain * Add tests for Xiaomi E1 driver curtain * Fix inverted logic * Add test for inverted logic * Comment out inverting percentage Apparently this is already done by the cover when "inverted mode" is enabled. Does this depend on firmware? * Add more custom attributes * Add illuminance measurement Possible values are 0, 1, 2 apparently * Add custom node descriptor for disabling "is mains powered" * Move imports * Comment out test for reverting lift percentage We're not inverting it ourselves at the moment * Make illuminance cluster a `LocalDataCluster` * Remove "TODO: `XiaomiAqaraDriverE1` in OUTPUT clusters?" Doesn't seem to be the case, but I'm not sure. * Remove commented code about inverting "go to lift percent" command * Remove commented code about inverting current lift percent attribute * Remove TODO for up/down commands * Change "attributes copy" to copy from `XiaomiAqaraE1Cluster` class * Move local illuminance cluster and custom PowerConfiguration class to main Xiaomi file They'll also be used by other devices (in future PRs) * Remove commented test about testing inverted percent attribute This functionality was removed, as it seems to be wrong according to comments in zigpy#2629 * Change comment for `WindowCoveringE1` cluster class * Add tests for custom light level attribute
Proposed change
#2620 should be merged first. This PR then needs to be rebased (for the test file).This PR will be merged first, other than rebased. It'll use some cluster classes from this PR.
Additional information
Supersedes #1648
Fixes #2003
Changes are all untested. I'm also not sure if this is the right way to use the motor mode. It's in the original quirk and a HA PR for the inverted motor mode has already been merged (even though the quirk was never merged).
There are still some TODOs in the PR (which is also why
pre-commit
fails).Checklist
pre-commit
checks pass / the code has been formatted using Black