Skip to content
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

Open
andriej opened this issue Aug 24, 2021 · 283 comments
Open

🔋 (Xiaomi) Batteries values are questionable #8499

andriej opened this issue Aug 24, 2021 · 283 comments
Labels
problem Something isn't working

Comments

@andriej
Copy link

andriej commented Aug 24, 2021

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 :/
image

Debug info

Zigbee2MQTT version: 1.21.0-4
Adapter hardware: CC2652P zStack3x0
Adapter firmware version: 20210708

@andriej andriej added the problem Something isn't working label Aug 24, 2021
@andriej
Copy link
Author

andriej commented Aug 24, 2021

And not to blame it only on door-window sensors (MCCGQ11LM), here are:

  • smoke sensors (JTYJ-GD-01LM/BW aka Honeywell Xiaomi)
    image

  • xiaomi buttons ( WXKG11LM and WXKG01LM )
    image

  • motion sensors ( RTCGQ01LM and RTCGQ11LM)
    image

And this installation is a-lot-months old already, so it's not fault of often restarts/rebindings or not gathered enough data...

@andriej andriej changed the title Batteries values are questionable 🔋 Batteries values are questionable Aug 24, 2021
@Shred99
Copy link

Shred99 commented Aug 25, 2021

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.

@andriej
Copy link
Author

andriej commented Aug 25, 2021

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.
On the same sensor.

@McGiverGim
Copy link
Contributor

As far as I know the sensor only sends the voltage, and z2m translates it into a percentage the best it can.
So if you don't see a change in the voltage, you will not see any change in the percentage.
Here is where it makes the magic:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/fe7d0ec950dec5af824e153220777806f29ac59a/converters/fromZigbee.js#L4277-L4301
and here (I think it uses the 3V_2100 option):
https://github.com/Koenkk/zigbee-herdsman-converters/blob/fe7d0ec950dec5af824e153220777806f29ac59a/lib/utils.js#L132-L168
The conversion from voltage to percentage maybe can be done better/different, but first you need the voltage to be changing.
Over 3 V it will always show 100%.

@andriej
Copy link
Author

andriej commented Aug 25, 2021

@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%).
Main question is - what's the difference with approach of Xiaomi Aqara gateway (for specifically Xiaomi sensors), that makes their values much more reasonable?

If sensors send it's voltage, are we 101% sure it's pure voltage without any calculations done?
I guess it's not difference in protocol - older Xiaomi gateways were zigbee 2 (the ones I had), newer ones are zigbee 3 already.

--
some time before migrating to z2m I've been using deconz, which also had different approach with battery reporting.
There was funny situation, when I've came across thread on smartthings forum, which had third approach of calculation. And the only reference I had was aqara gateway, which was the closest to reality (in perception of percentage, not voltage)

@McGiverGim
Copy link
Contributor

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.
The method z2m uses for the percentage is the best z2m found, because z2m don't know how Aqara/Xiaomi converts the voltage to percentage. If someone knows how it does this conversion, it can be changed to be similar.

@andriej
Copy link
Author

andriej commented Aug 25, 2021

I started to dig some once again, as maybe there's a oppoturnity for some fine tuning.
So, calculations are/were (don't know, don't use) in ZHA too: home-assistant/core#44578
but!
I've found some nice battery-level count method, which I've checked with one of my sensors:
https://community.home-assistant.io/t/xiaomi-aqara-battery-level/36222/14

So, taking a look at:
(2.8 is 'completely dead, 2.9 should be considered to exchange):
image

z2m shows 100%, solid
while:
Math.min(Math.round((voltage - 2200) / 10), 100) found and used in nodered is:
((3025 - 2200) / 10) -> 82,5%

and that's the value I could believe, because I remember that I was exchanging that battery some time ago already.
Let's take a look on the other one I've changed earlier:
(3085 - 2200) / 10 -> 88,5%

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% ;-)

@Koenkk
Copy link
Owner

Koenkk commented Aug 25, 2021

@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.

image

@andriej andriej changed the title 🔋 Batteries values are questionable 🔋 (Xiaomi) Batteries values are questionable Aug 25, 2021
@andriej
Copy link
Author

andriej commented Aug 25, 2021

@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:
image
WSDCGQ11LM and WSDCGQ01LM

Maybe they get different counting schema and that's why their values are more to be respected?
I don't have much more stuff from Xiaomi with batteries, but also have GZCGQ01LM outside house.
Would you believe it has 100% after winter out there? ;-) It's voltage is 3000, so below what's 100% (new battery), but z2m shows as 100%.

I hope maybe more people will join the thread and solution may come later on.

@rindlerblabla
Copy link

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%.

@McGiverGim
Copy link
Contributor

One of my WSDCGQ01LM is low too:

image

I will keep an eye on it too, but I'm pretty sure it can last some months with this battery level. And I suppose different devices will have different dead levels.

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the stale Stale issues label Sep 25, 2021
@andriej
Copy link
Author

andriej commented Sep 25, 2021

Still valid I guess

@github-actions github-actions bot removed the stale Stale issues label Sep 26, 2021
@zen2
Copy link

zen2 commented Oct 16, 2021

I'm come here following two dead batteries on xiaomi temperature/humidity sensors.
Last battery % i get from this sensors was respectively 91%(2985mv) and 100%(3005mv).

I suspect several things about % calculation:

  • calculation is not linear since battery discharge is not
  • calculation is depending on temperature/humidity
  • different kind of sensors can have different minimum voltage to work properly
  • discharge is depending on resistive load of device
  • possibility that xiaomi gateway battery calculation is based with a 100% based on new battery voltage

So it's a complex topic to find the perfect solution.
I can see only two way to find an acceptable solution:

  1. the best one: retro-engineering of xiaomi gateway (or may be application ?)
  2. use a xiaomi gateway and try to guess a general formula depending of voltage seen, battery % from gateway/app, kind of sensors, temperature/humidity
  3. create a central database of voltage for different kind of sensors from several users to determine minimum voltage for each kind of sensors

For the battery problem alert, actually it's not possible to rely on % battery for all kind of devices by experience.
I actually use last_seen report to detect died battery since sensors emit regularly and suddenly stop.
But I can't see a way to alert before battery die.

Complete PDF about CR2032 lithium battery: High pulse drain impact on CR2032 coin cell battery capacity

@ristomatti
Copy link
Sponsor

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.

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the stale Stale issues label Nov 24, 2021
@andriej
Copy link
Author

andriej commented Nov 24, 2021

Still valid

@McGiverGim
Copy link
Contributor

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...

@github-actions github-actions bot removed the stale Stale issues label Nov 25, 2021
@larod241
Copy link

larod241 commented Dec 1, 2021

Hi,

To help, my WSDCGQ11LM stop working.
Last values before it die :
Capture d’écran 2021-12-01 à 09 18 46

Hope it can help.

@Koenkk
Copy link
Owner

Koenkk commented Dec 1, 2021

@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)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2022

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

@github-actions github-actions bot added the stale Stale issues label Jan 1, 2022
@github-actions github-actions bot added the stale Stale issues label May 12, 2023
@DannyFeliz
Copy link

Bot, please 🙏🏻

@github-actions github-actions bot removed the stale Stale issues label May 13, 2023
@herbalizer404
Copy link

Same issue here, can we have a fix please

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the stale Stale issues label Jun 26, 2023
@andriej
Copy link
Author

andriej commented Jun 26, 2023

Bot, please don't

@github-actions github-actions bot removed the stale Stale issues label Jun 27, 2023
@d-buschmann
Copy link

Same here!

@MattHadfield113
Copy link

I have noticed this, but have also noticed that in my "Exposes" i can manually refresh which seems to poll the latest status, is there a way we can automate this?

@andriej
Copy link
Author

andriej commented Jul 20, 2023

I do not see any option to refresh in "Exposes". Maybe it's device dependent? (at least looking at aqara sensors)

@MardariG
Copy link

this issue is from 2021, nobody using aqara devices? ;/

@zen2
Copy link

zen2 commented Aug 17, 2023

Update on relationship between voltage and temperature:

I use a lot of temperature/humidity/pressure sensors Xiaomi Aqara WSDCGQ11LM.
Check this three month of three of them (exterior, wine cave, fridge):

image

So it's clear that reported voltage depends on temperature and so only voltage is not enough to predict end of battery.
That's why almost all Aqara devices report temperature (even if not calibrated).
The sensor temperature should be used with voltage to give the battery % level.

@mkaatman
Copy link

@zen2 it would be interesting to see a screenshot right before the battery dies. Does the pattern break or is it consistent?

@zen2
Copy link

zen2 commented Sep 4, 2023

@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.
Usually you do not see a battery voltage variation right before batteries dies.

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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2023

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

@github-actions github-actions bot added the stale Stale issues label Oct 5, 2023
@andriej
Copy link
Author

andriej commented Oct 5, 2023

Come on, bot

@github-actions github-actions bot removed the stale Stale issues label Oct 6, 2023
@OZ1SEJ
Copy link

OZ1SEJ commented Oct 7, 2023

I have the same problem with all my Aqara door/window sensors:

image

However, most (!) of my Aqara temperature, pressure and humidity sensors actually report a battery percentage less than 100:

image

How come (most of) the weather sensors show a battery percentage less than 100, when the door sensors don't?

@luispereira
Copy link

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...
Xiaomi sensors works tho

@Smandurlo
Copy link

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.

@OZ1SEJ
Copy link

OZ1SEJ commented Oct 20, 2023

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...

@stickpin
Copy link

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?

@OZ1SEJ
Copy link

OZ1SEJ commented Oct 20, 2023

it is... you just need to enable it. it's disabled by default.

Wow - how do you do that?

@Smandurlo
Copy link

Screenshot_2023-10-20-16-11-04-384_io homeassistant companion android-edit

@stickpin
Copy link

Screenshot 2023-10-20 at 16 08 43

Screenshot 2023-10-20 at 16 11 30

Screenshot 2023-10-20 at 16 09 25

Screenshot 2023-10-20 at 16 10 00

@r0m1CH
Copy link

r0m1CH commented Oct 20, 2023

Works well. But how do you use the mv then ? how to know which percent it represents ?

@flg
Copy link

flg commented Jan 12, 2024

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.

@jehy
Copy link

jehy commented Jan 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests