-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🔋 (Xiaomi) Batteries values are questionable #8499
🔋 (Xiaomi) Batteries values are questionable #8499
Comments
And not to blame it only on door-window sensors (MCCGQ11LM), here are: And this installation is a-lot-months old already, so it's not fault of often restarts/rebindings or not gathered enough data... |
Are you sure that this is a problem with Zigbee2MQTT? As far as I know, all it does is publish the values transmitted by the ZigBee sensor. I have quite a number of Xiaomi sensors that have been in service for 2-3 years... possibly longer. I'm currently seeing most of the door switch sensors reporting battery health in the 91% - 100% range. I have three environment (temperature/humidity/barometric pressure) sensors that send updates quite frequently. One of them recently needed a new battery and I was able to see the voltage and battery percentage trend down over time, before the sensor finally stopped transmitting. |
I'm almost certainly sure, as those sensors in xiaomi aqara gateways and it's app reported values that seemed reasonable. Much more reasonable. So 90% after few months is much more reasonable than 100% after 3 years. |
As far as I know the sensor only sends the voltage, and z2m translates it into a percentage the best it can. |
@McGiverGim I'm aware it's z2m that does the calculation. I've opened the issue because I'm somehow nervous about not having oppoturnity to i.e. exchange batteries before I go for holiday, because I can see they're low (i.e. <20%). If sensors send it's voltage, are we 101% sure it's pure voltage without any calculations done? -- |
It works with the data the sensors sent. Nothing more. If it is the real or some strange calculation voltage I can't say. The same does the Aqara/Xiaomi gateway as far as I know. |
I started to dig some once again, as maybe there's a oppoturnity for some fine tuning. So, taking a look at: z2m shows 100%, solid and that's the value I could believe, because I remember that I was exchanging that battery some time ago already. I'm just not sure if taking '2500mV' to account is proper way for calculation, as I don't think any xiaomi sensor will report anything with battery lower than 2.8V It's open for discussion, I'd just like to have my fav software fine-tuned in that aspect too... and cut the myth of 100% ;-) |
@andriej since we focus on Xiaomi devices here, could you change the title to mention Xiaomi? My WXKG02LM_rev1 currently reports the following so it should drop off soon, will keep an eye on the last known voltage before it stops working. |
@Koenkk this will be surely nice catch - the sensor that was the reason of starting this thread has gone out with 3035 (last value I see in HA) and I'm even more worried about it right now. ;-) To not be blamed of being 100% pesimistic - there's something 'better' in calculating temp/hum and temp/hum/press sensor: Maybe they get different counting schema and that's why their values are more to be respected? I hope maybe more people will join the thread and solution may come later on. |
I have some 20 of those contact sensors. Those reporting 3015-3025 mV report 100%, 2995 mV report 97%, 2985 mV report 91% and 2975 report 86%. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Still valid I guess |
I'm come here following two dead batteries on xiaomi temperature/humidity sensors. I suspect several things about % calculation:
So it's a complex topic to find the perfect solution.
For the battery problem alert, actually it's not possible to rely on % battery for all kind of devices by experience. Complete PDF about CR2032 lithium battery: High pulse drain impact on CR2032 coin cell battery capacity |
Has anyone tested the accuracy of the sensor voltage readings with a decent quality multimeter or compared readings between two devices with the same battery? My guess would be the values might vary quite a lot. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Still valid |
I'm waiting to see when my device dies. The latest report was at 40%, the 25th august. Now is at 29% (2.815V) and working... |
@larod241 thanks, I will keep track of these values here: https://pastebin.com/64HP9i10 (so others please also report the last voltage before it dies) |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
@zen2 it would be interesting to see a screenshot right before the battery dies. Does the pattern break or is it consistent? |
It will be consistent because battery reporting is done less often than sensors reporting. I'm sure that % battery level depends on temperature (that all xiaomi aqara devices report) and that low voltage limit is different for each kind of devices. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Come on, bot |
Yeah this is happening to me too, battery on aqara sensores are always 100% until they no longer have beterry and I realize they are no longer transmitting... |
Unfortunately I can confirm it. My window/door sensors just used to stop to work and the battery was 100% or so. Now I just look at the voltage (mV) and do my own math: problem solved. |
But zigbee2mqtt doesn't send the mV reading to Home Assistant - right? (Why not?) I don't have any mV readings in HA... |
it is... you just need to enable it. it's disabled by default. @Smandurlo to you have a template to do the math? |
Wow - how do you do that? |
Works well. But how do you use the mv then ? how to know which percent it represents ? |
Just to mention that the same problem happened on a Aqara E1 TRV, i.e. Xiaomi SRTS-A01. I've enabled voltage reading and will add information at the end of the next battery cycle. |
Same here with Xiaomi WSDCGQ11LM. Still 100% and 3005mv after a year of constant reporting. But I don't think there is much we can do with it. |
Check mW... If it's over 3V you have 100%. If it's under 3V then you have less then 100%. The battery drain faster with less then 3V... |
@Koenkk : as many users report that ZHA display batteries voltage correctly I've dived in homeassistant code to find how they calculate it. In fact homeassistant ZHA component is based on zigpy. Battery calculation in Zigpy code:
Another related and interesting code is the zha xiaomi test code: As far as I understand they seems to use 2820/3100 mV for 0/100 % per default and min/max voltage can be overridden by device quirks. |
2820/3100 mV for 0/100 % per default and min/max voltage So, if you decide here to use this values you get a problem. Some device will show 85%, but battery changed before. I do it yesterday and don't have 3100 mV. So my device show 3053 mV. Wise versa to undervoltage. You have 2850 mV and my device stop working. But it shows me 10% of charge. So that also bad as well. If you work with Voltage and you want to calculate battery state, you need upper and lower percent that save you for mistakes. Each battery manager work like this. |
@zen2 it's also just a linear calculation, z2m uses 2850 <-> 3000, while ZHA uses 2820 <-> 3100. If that's better, we can easily change to that. |
That isn't better. That's worse. I don't have any device starts with 3100 mW. If we set this to 3100 then all my device never will show 100% full state. That's stupid then. |
The different capacities of battery's are a problem either. If you have a CR2032 capacity is 225mA...if you have a CR2450 you have capacity of 650mA. We have then other Voltages. We have this issue with different types and we have also different Voltages and we have non linear uncharging. You can solve this only within this devices itself. But we can't. We get only the voltage and don't have any clue about capacity. That is the big problem here... When we say hey we have 2% range around 3100 then we get a good value for 100%... That means a range between 3100-2% also for 3100+2%... Then you can start with calculation an we get something around 3035... So then we have 100% but at the end... It doesn't matter what we calculate, with linear calculations we are affected and dependent on uncharge curve of the battery... And draining will be faster at the end. So what should we do now? If we put it to 3100 mW no of my device or the most of them will show all times under 100%. I will never get 100% anymore with a new fresh battery. |
I think while the current solution isn't perfect, at least you get an estimate of the battery charge. I agree with @Wikibear - The easiest solution to the inaccurate battery stats is to use an automation that checks if all of the device's sensors stay unchanged for a period of time. This usually indicates a weak or dead battery. It's not ideal as you might lose some information during its downtime if the battery really is dead, but I for example have no sensors that are so important, that they'd have to have 100% uptime. |
@stickpin: It's a never-ending story... Replace battery and life is back ! :)
Most sensors have an end-of-life voltage that follows a logarithmic curve that accelerates until the battery dies, but some have a voltage that drops suddenly before the battery is dead. In short, I agree with @Wikibear and @johannes-z, the battery percentage is just an indicator and it's better to rely on another strategy for replacing batteries. Personally, I always have spare batteries ready to use and I get an alert if I don't have any reports from a device within 2 hours. The Aqara sensors send at least one report per hour. For me that's more than enough and the batteries are fully used. If I wanted to guarantee continuity of service for a sensor by replacing the battery before it died, I'd look at the voltage derivative or, more simply, I'd trigger an alert if the voltage dropped by more than a certain delta over a certain period of time. And if it's really important, all you have to do is observe the discharge time in general per type of device and change the battery regularly according to how long it's been in use. |
I also agree, but it's maybe not the best solution. Making an automation based on the percentage is way way easier to understand for non power users. Looking at derivative, delta, or making an automation based on the last time a device reported are already an advanced way of doing things imo. A simple user will probably never think like that. That's why I think that we need to have a "reliable" percentage. Maybe it's ok that limits (0 and 100%) are rounded or faked, because anyway having a device close to die is the same has being dead: it's time to changes batteries. |
I gave it a shot. This conversion is based on battery manufacturer specs on how much energy is left depending on the voltage. However, this also depends on the temperature - which, well is available here, but I don't want to go down this rabbit hole ;) The different voltages are somewhat non-linear, so I converted it somewhat non-linear. It should show 90% or higher for a full battery, depending on the ambient temperature and how old the battery stock is. I think that's a good compromise. This however also doesn't take into account that some devices have a pretty high minimum voltage which they will operate on, like @zen2 showed for the WSDCGQ11LM which seems to be around 2.8 V. Usually, you would expect that the devices can at least run the battery down to 2.6 V, which is why this is shown as 0% in the conversion. |
What happened
My few-years-old door window's sensor from Xiaomi died. With it's battery value until the last day reported at 100%.
What did you expect to happen
To see battery value more-real, probably like values from Xiaomi Gateway.
Was waiting with this report, but I have to admit - there's an issue with battery reporting/gathering in z2m.
Before I've moved to z2m I had most of the sensors I have now conencted to Aqara gateways - each of them was reporting their value getting lower and lower, was much easier to see which sensors had around 40% and which 60-70.
Right now it's total guess game.
What could be the reason behind it? I know the value of voltage is reported - but it doesn't change during the time pass - the sensor died had the same 'voltage' report as all other sensors have - 3035 mV. So it's purely wrong information.
What Aqara gateway does differently? May it be Xiaomi-specific handling for implementation?
I hope the discussion starts and z2m will get even better - currently it's the last struggle I have with my installation, everything else works just fine
How to reproduce it (minimal and precise)
Just look at list of all door-sensors I have since few years.
Can't see or even guess when they willl die, before 'availability' kicks in :/
Debug info
Zigbee2MQTT version: 1.21.0-4
Adapter hardware: CC2652P zStack3x0
Adapter firmware version: 20210708
The text was updated successfully, but these errors were encountered: