colinbendell / homebridge-blink-for-home

Blink For Home Camera Homebridge plugin
MIT License
88 stars 27 forks source link

Batter Low #58

Closed inmaterichard closed 3 years ago

inmaterichard commented 3 years ago

Hi, the app seems to work excellently within HomeKit, although I'm having a small issue, the device it's displaying 'Low Battery', although it's reporting a battery level of 72%, any ideas how I can change the threshold for what defines low battery?

Screenshot 2021-02-24 at 17 25 06

colinbendell commented 3 years ago

The 72% is a bit misleading and should probably be updated. Currently it is calculated as battery_voltage / 180 * 100. Clearly what this is showing is that the voltage is down to 1.3V. Since it's an AA battery, it's not like modern Lithium Ion batteries like we find in laptops since the the voltage level usually drops quickly near the end of life. (Usually around 1.8V for a long period and then drops to 0 in a very short period of time at the end of life)

All that to say, battery life math is wrong and I need to find a better way to convert alkaline battery voltage to battery level.

colinbendell commented 3 years ago

I've revised the calculation to report 10% if the low battery indicator is tripped; Otherwise it will use a ratio of [(voltage - 1.2) / (1.8-1.2)] * 80 + 20 which effectively uses a voltage of 1.2 to 1.8 to represent the range of 20% to 100% battery. It's crude but will better map to our Li+ battery expectations.

This was shipped in v3.7.2