-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improved battery level accuracy with updated voltage-to-percentage calculation #7929
base: master
Are you sure you want to change the base?
Conversation
d195061
to
43b8b42
Compare
@Koenkk I guess it would make sense to adapt the "3V_1500_2800" conversion as well? |
Where is the calculation based on? |
I've explained that here: Koenkk/zigbee2mqtt#8499 (comment) It's a mix of two things: Remaining battery energy capacity specs by battery manufacturers and the fact that most devices won't accept 2.5 V and will often struggle with 2.6 V. So the remaining battery energy capacity below 2.7 V is ignored - because it's not useable. For specs see: https://www.duracell.com/wp-content/uploads/2021/06/CR2032CH_245mAh-CS.pdf |
I see, note that this change won't affect Lumi devices (which are often referred to in Koenkk/zigbee2mqtt#8499) since those use e.g. |
Where do min/max come from? Does the device send those? Like is that the measuring width of the voltage meter on the device or something like that? In this case I would change the PR to do the same conversion like above, just clamp the maximum value (and everything above) to 100% and clamp the minimum value (and everything below) to 0%. |
…lculation - Updated the voltage-to-percentage conversion to provide a more realistic view of battery levels, especially at lower voltages. - The previous method sometimes showed full or half-full batteries even when they were actually low.
56cb839
to
b4c1184
Compare
I believe these values came from Koenkk/zigbee2mqtt#8499, everything below 2850 mv is considered dead |
Ah, alright. I've looked through my dead battery container yesterday, and they were either below 1 V or between 2.6-2.7 Volt, measured with a multimeter. So most of my sensors must have kept going until 2.7 or 2.6 Volt — despite being made by Xiaomi. So my suggestion would be to keep the minimum voltage variable, which can be set if we know a specific voltage at which the device will usually stop working. If it is set, the percentage calculation is modified to reflect this. The upper end however isn't needed. If you like this solution, LMK and I implement it. |
Maybe I'm not understanding it, but that's what we do right? It may be a bit on the high side but the voltage at which the Xiaomi devices dies is somewhere between 2600-2850mv. |
Well, I was thinking more about a way to specify the minimum operation voltage for a device. So if users report back, that a device always dies at 2900 mW instead of the expected 2650 mW, we can set a variable and the calculation adjusts to show 2900 mW as 0% for this device. This would avoid that certain device types always die with 40% battery left or something like this. |
That's already possible, see zigbee-herdsman-converters/src/devices/bosch.ts Line 1124 in 00ed002
|
Fixes Koenkk/zigbee2mqtt#8499
Comparison