My Smart Home FHEM alway shows Lowbat warning with my new Xiaomi devices although they are 1 week old.
Could you please check if the battery level is calculated correct?
Thx
@kaelsaes Can you please let us know which version of zigbee2mqtt you are using?
The battery is calculated using:
const battery3V = {
min: 2800,
max: 3300,
};
battery: toPercentage(voltage, battery3V.min, battery3V.max),
md5-fa8b6e52cf6e5b8e1fe571b0bbae63b5
const toPercentage = (value, min, max) => {
if (value > max) {
value = max;
} else if (value < min) {
value = min;
}
const normalised = (value - min) / (max - min);
return (normalised * 100).toFixed(2);
};
You can find details in https://github.com/Koenkk/zigbee-shepherd-converters/blob/master/converters/fromZigbee.js
This is the current setup also in home assistant. What % does FHEM report low battery?
Version 0.0.0
battery | low | 2018-06-22 22:15:24
battery_level | 69.00 | 2018-06-22 22:15:24
click | single | 2018-06-13 19:27:02
state | click_release | 2018-06-13 19:27:02
transmission-state | incoming publish received | 2018-06-22 22:15:24
voltage | 3145 | 2018-06-22 22:15:24
@kaelsaes besides 0.0.0 there should have been also a hash.
69% should not be low, so some other attribute is triggering this. Zigbee2MQTT doesn't publish battery: low
@ciotlosm
Okay, thanks. I will contact the author of the FHEM modul.
@kaelsaes The two sensors I have added did not start at 100% and after one week the human body sensor is at 45% and the temperature is at 35%. As the % lines up with the voltage I tend to believe it. I think there might be some old stock getting sold!
Okay, thanks.
I inserted a completely new CR2032 battery and it started with voltage 2995 and 39% battery level.
But a 3 V battery can never have 3,3 V. Why do you calculate with max 3,3 V?
We kept this the same as the xiaomi aqara component for home assistant (https://github.com/Koenkk/zigbee-shepherd-converters/commit/6101411c111cf49372e4e1c20317cdfb4e008a6c). But this indeed seems unlogical.
@ciotlosm what do you think about reverting to the 2500-3000 range?
@Koenkk I tried to do a little research, and there are various assumptions out there.
Things to take into consideration:
Happy to go back to maximum being 3000 (as that is the spec most sites agree on as initial) >= 3000 to be 100%, but maybe consider minimum to be 2700.
@ciotlosm Thanks!
@kaelsaes can you close this issue if everything is OK?
Thanks for your quick help.
I had the same error while using new batteries.
Is it fixed by update to newest Zigbee2MQTT by the following commands?
git checkout HEAD -- npm-shrinkwrap.json
git pull
rm -rf node_modules
npm install
@Sonsi79 here you can find how to update: https://github.com/Koenkk/zigbee2mqtt/wiki/Running-the-bridge#6-for-later-update-zigbee2mqtt-to-the-latest-version (that should fix your problem).
I works fine for me. Thanks a lot
Sorry to reopen, but my WSDCGQ11LM shows 2,995v and calculated 55% of battery. This seems to be a little bit odd if the battery range is 2700 - 3000.
@cyable how do you know the range is 2700-3000?
I also get the Low bat error on Batteries which are ok :(
@Koenkk Based on the discussion process in this issue, I assumed that (As mentioned on 24. Jun).
Fixed now in the dev branch.
Offtopic: Could somebody make a PR on how to integrate with FHEM? (https://github.com/Koenkk/zigbee2mqtt/blob/master/docs/index.md#integration)
Switched to dev branch, 2,985v, 95%, great!
Offtopic: I have only one Xiaomi Temp.-Sensor to test with FHEM, but second CC2531, a Xiaomi motion sensor and spare Ikea & Osram light bulb are on the way to test FHEM integration further. So, I have very little experience with zigbee2mqtt <-> FHEM at the moment.