-
Notifications
You must be signed in to change notification settings - Fork 721
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
Fix power measurement for Aqara MAEU01 plugs with newer firmware #1656
Conversation
Codecov ReportBase: 80.06% // Head: 80.37% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev #1656 +/- ##
==========================================
+ Coverage 80.06% 80.37% +0.31%
==========================================
Files 240 240
Lines 7455 7482 +27
==========================================
+ Hits 5969 6014 +45
+ Misses 1486 1468 -18
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Pull Request Test Coverage Report for Build 3267161994
💛 - Coveralls |
def power_reported(self, value): | ||
"""Power reported.""" | ||
self._update_attribute(self.POWER_ID, value) | ||
self._update_attribute(self.POWER_ID, value * 10) |
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.
This change made my another aqara outlet (mmeu01 square one) report 10* more usage than normal
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.
That should be fixed by either re-pairing the device or reading the "ac_power_divisor" attribute on the ElectricalMeasurement cluster through ZHA -> Devices -> Plug -> Manage Clusters -> ElectricalMeasurement -> ac_power_divisor -> read attribute.
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.
Reparing is workaround, I don't think this is good user experience to ask user to re-pair working device,
I think the solution is to remove this multiplication and change ac_power_divisor back to 1, I've changed it locally and both devices shows power consumption correctly for me
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.
I agree. If possible, the "fake" attribute should be re-read automatically. There is another issue with it being left on 1 (different rounding when values like 1.9W are reported which causes a jump from 2W to 1W after some time with unchanged consumption).
If consumption varies a lot when low, it's also nice to see values in between 0W and 1W (and it not constantly jumping around).
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.
The power measurement on LLKZMK11LM (lumi.relay.c2acn01) is also wrong after this change. It's showing 100W for a 10W device.
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.
@hakong No, check the AC power divisor: 0x0605
. It's set to 10
instead of 1
now. Both of these changes were made so that there's one decimal.
1b511ab
to
72706fd
Compare
I've updated the custom quirk and total power consumption might work after some time now. Before testing anything, it's recommended to reset and re-pair the plug! Some values might be off otherwise. Edit: Updated again. MAEU01 and MMEU01 total power consumption should work now (re-pair device!) Note: When restarting or manually polling |
I've updated the quirks and let you know if the total power consumption is now working ! One quick question, the plug has the hability to resume power on power loss. This is not the default behaviour (does not resume power by default). With Z2M, we had access to this settings directly. It's also described on the device page : Enable/disable the power outage memory, this recovers the on/off mode after power failure. Value can be found in the published state on the power_outage_memory property. To read (/get) the value publish a message to topic zigbee2mqtt/FRIENDLY_NAME/get with payload {"power_outage_memory": ""}. To write (/set) a value publish a message to topic zigbee2mqtt/FRIENDLY_NAME/set with payload {"power_outage_memory": NEW_VALUE}. If value equals true power_outage_memory is ON, if false OFF. With ZHA, I cannot find it, nor using "Set Cluster" options. Do you have any idea how should I do that ? Regards, |
I updated the quirks. (No need to re-pair when coming from the previous version). Under |
Thanks ! Smartenergysummation has started to returns value ! |
Mhm, that's weird. It works on the plugs I tested it with. Reading the attribute before re-opening the window also shouldn't be able to get another value (None) at all. Can you turn on ZHA debug logs and see if there's anything in the logs when reading or writing the attribute? Also, make sure you're not using the lower text field with "manufacturer code override". That should always stay empty. So only use the upper one with writing 0 or 1. When reading the attribute, it will show in the same text field (but Bool.false/Bool.true). |
Ok, now I feel dumb, i've never used custer attributes to write attributes so I was using the "Manufacturer code Override" because the "value" was filed with 'Bool.false'. Works like a charm using the correct textfield ! |
Looking good here too on my 2 lumi.plug.maeu01. Only one useless sensor is created, but I think you already mentioned that (sensor.lumi_lumi_plug_maeu01_electricalmeasurementpowerfactor_2). The rest seems to work fine and update as well, many thanks! |
@fmiermont It's not really a user-friendly way. If/when this quirk gets merged officially, an option could be added to HA itself, so the clusters menu doesn't even need to be used. |
My two maeu01 plugs also works with "Electricalmeasurement", "Smartenergysummation" and the new "power_outage_memory" setting. Thanks! :) |
@TheJulianJES yes I know this is not the user friendly way to set this parameter but this is also the basics of "advanced" zwave settings and I'm usually familiar with this (but i'm not using HA for a long time). |
Thanks a lot for your work! It's working for me as well 👍 (MAEU01, app_version = 41) |
FYI for anyone that is using IKEA remotes and firmware v41 on the The plug includes a rudimentary downgrade check that can be bypassed. I've successfully downgraded one of the plugs I'm testing with from v41 to v32. Be aware that you could brick your plug! The quirk is now also updated to support |
I tested the latest quirk with 3x v41 plugs, all work great. Thanks for the quirk! |
Hi Just wanted to give my input on this, i have a total of 5 Aqara Smartplugs and i have mixed luck with this and the original quirk shipped in 2022.9.7 of Home assistant, in the original one the connection to my plugs with .41 firmware is stable, but no power readings what so ever, in this this one i get power readings but the plugs constantly goes unavailable but i get power readings from them. i have 3 with .41 firmare and 2 with .32 and the old ones work with either quirks. I have removed one of the plugs after i added this and reinstalled it, same problem. Just wanted you to know that it does not work for every .41 plug sadly. If there is something specific you want me to post about my plugs i will gladly do so. Regards / Marcus |
@muddenhed The quirk can't affect the connection stability. It only changes how the messages are parsed when coming from the plug. With these plugs, I haven't encountered any stability issues so far. What coordinator/stick are you using? (Also FYI, you can upgrade or downgrade all plugs to whatever firmware version you want (32 or 41)) |
Hmm, intresting, wieard that it starts acting like that then. Sorry for wasting your time on this, thought it containted some connection polling code in this, but know better now. Thanks. |
You didn't! Thanks for all the feedback.
Mhm, I've heard of quite a few issues with ConBee sticks now. You could try to upgrade the firmware on the stick and see if that helps.
Process should basically be to download the modified firmware image, put the image in a zha_ota folder that's registered in the configuration.yaml, send a cluster command to notify the device of the OTA, wait until the device updates, delete the image from the zha_ota folder and restart HA (so the device doesn't "upgrade"(downgrade) again). |
Writing the OppleMode, for some reason, always times out but still writes the attribute successfully.
The quirk is now included starting with Home Assistant Core 2022.10.5 (and later). If you didn't install the custom quirk and have issues with your Aqara MAEU01 or MMEU01 plugs now, please remove the device from ZHA and re-pair it. If you still have issues then, create a new issue in this repo and tag me. |
I just got three of these plugs, first tried to install one of them this evening. It did not work so I got searching for why, and found this thread. Now I have updated to: But it still do not function, I have tried to install one of the other ones I got but the result is still the same. I got ZHA and the Raspbee II, where do I go wrong? Best regards Freddy. |
I'm facing the same problem. I have 2 switches of this type. One is recognized, the other is not recognized or already recognized but I don't get any values displayed. The other connector works with no problems. My HA is 2202.10.5, everything is up to date. Greetings, Maggi |
This is actually really frustrating. Have spend hours searching and I do have to conclude that my knowledge isnt good enough. Hope this is posible to solve then. |
@TheJulianJES any idea how I can solve this? Today I updated the firmware on my Raspbee II, but still none of my plugs reporting any measuring, only function is on off. |
@FSHelgeland So, you re-paired the plug after updating your Raspbee firmware and it still doesn't work? |
Hello @TheJulianJES , I have Home Assistant 2022.11.1 as well and only the switch is working. Then I tried installing the quirk but it does not work anyway... |
@sipy Did you do the above? Also, remove any custom quirks for the plug. They're all in Home Assistant 2022.10.5 or later (so also in 2022.11.1). |
Yep @TheJulianJES , tried them all and still not working. I am now trying to downgrade the Aqara firmware from V41 to V32. I'll let you know if it works. |
Also, like I mentioned, please create a new issue here and fill-out the template: https://github.com/zigpy/zha-device-handlers/issues/new/choose |
@TheJulianJES Shame on me... Like my students I told you I had done something that I havent. But now I have updated my Raspbee II firmware to the latest one, and now I am able to read at least the active power, and also the correct device temperature. Cant read the voltage, but I dont need it, as long as I can read the active power I am satisfied. Thank you for solving this. EDIT: And suddenly the voltage appeared, now it works like a charm :-) |
@FSHelgeland Nice, glad it works for you now! (Voltage always takes some time to appear after initial pairing due to how Xiaomi's messages work and I'm also not sure how accurate it is lol) |
@TheJulianJES , downgrading the Aqara firmware from V41 to V32 following this guide Koenkk/zigbee2mqtt#13903 (comment) solved the issue. Thank you. |
@sipy Yeah, that's works around the issue you were having. It's the recommended firmware anyway, but, so far, it looks like your Raspbee firmware didn't correctly update if the older plug firmware works and the newer one doesn't. The newer firmware versions requires Xiaomi manufacturing codes to be sent using pairing. That's implemented in deCONZ firmwares since 1 or 2 years. I'm glad that it finally works for you. |
Thanks @TheJulianJES , in order to be sure that I will face no issue in the future I should disable any updates of the Aqara plug firmware, right? How can I ensure that this will not happen? Thanks |
@sipy Just remove all Xiaomi plug related OTA files from your ZHA OTA directory and don't put any new ones in there and you're set. |
I just bought a new Aqara Smartplug and it didnt show up any values! Tried the quirk here but it didnt work. Any workaround? |
News
The quirk is now included with Home Assistant Core 2022.10.5 (and later). Please upgrade to that version.
If you have issues with the Aqara MAEU01 / MMEU01 plugs, then delete the plug from ZHA and re-pair it.
If you installed the custom quirk previously, please uninstall it now.
AGAIN: THE QUIRK IS INCLUDED WITH Home Assistant Core 2022.10.5 (and later).
Just pair the plug normally.
If there any issues, create an issue here: https://github.com/zigpy/zha-device-handlers/issues/new/choose
(Conbee users might need to update the coordinators firmware)
An alternative is downgrading the plug if there are still issues: Koenkk/zigbee2mqtt#13903 (comment)
The quirk is included with Home Assistant Core 2022.10.5 and later
Notes
This quirk will allow for the power outage memory to be enabled with a config entity in HA with:
This quirk will probably only work if:
the MAEU01 plug has(should work with all firmware versions now)app_version = 41
(couldn't confirm with older firmware versions) ANDmaeu01
plugs with new firmware and as the sensors of those weren't working at all before, it's not really an issue. Older plugs seem to use OppleMode instead of needing Xiaomi manufacturer codes at pairing to determine whether or not to send the special Xiaomi messages)This quirk (as of right now) will break power measuring in other MAEU01 plugs if:
the plug is running older firmware ORIf anyone needs the quirk right now, you can install this as a "custom quirk". See the instructions at the bottom.
Would fix #1655
As of right now, the newest firmware for the MAEU01 can be found here: Koenkk/zigbee-OTA#140 (41)
Older firmware is available here: Koenkk/zigbee-OTA#159 (32)
For downgrading your firmware, refer to the "Plugs randomly toggling on/off when using IKEA remotes" section of this post.
It's possible that this also fixes an issue with MAUS01 plugs (#1654) where sensors aren't created because there's no default value.
Changes
rms_voltage
instead of wrongly usedinstantaneous_voltage
attribute (sensor isn't created for instantaneous voltage (and it's wrong, as we deal with AC voltage here and the sensor always reports the "max" of the sin wave)TODO
make this work without breaking power measurement on older plugs paired without Xiaomi manufacturer codes/older firmware (or force everyone to update firmware?) (how to determine in which state we are?)provide custom quirk download linksalso get the alternative signatures of the older MMEU01 plugIt's possible thatcurrent_summ_delivered
needs to be polled, as it doesn't seem to update (Reference: Update lumi.plug to report total energy #1211)check if we still need to writeEdit: We wantOppleMode
to0
.1
might be better? (default forMMEU01
plugs with older firmware. For those, this quirk seems to work fine with both.OppleMode
seems to be removed on newer firmware versions).OppleMode
set to1
if it exists, so special Xiaomi attribute reports are sentfigure out if Xiaomi Aqara Plug (SP-EUC01/lumi.plug.maeu01) Toggles without reason Koenkk/zigbee2mqtt#13903 can be solved. (IKEA remotes routing through these plugs trigger toggle)Edit: by downgrading firmware (refer to the "Plugs randomly toggling on/off when using IKEA remotes" section below)Testing
New instructions:
Old instructions:
In the
configuration.yaml
, add this:In the
/config
directory, create a folder calledzha_custom_quirks
, put thetjj_custom_aqara_plugs
folder from this ZIP file in it: zha_custom_quirks.zipIn the end, the folder structure should look like this:
/config/zha_custom_quirks/tjj_custom_aqara_plugs
The last folder should contain four files:
__init__.py, plug.py, plug_eu.py, plug_maus01.py
Plugs randomly toggling on/off when using IKEA remotes
There's an issue in the v41 firmware on the plug where IKEA remotes toggle the plug (because the plugs always listens to messages sent for group 0). This is somewhat fixed in current versions of
zhaquirks
and this custom quirk by making the plug explicitly leave group 0. However, the plug still reacts when messages from those remotes are routed through it.See the following comment for further explanation and a link for how to downgrade your plug to a "non-broken version": #1656 (comment)