home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.47k stars 29.4k forks source link

Battery Still Bogus #109826

Closed def1149 closed 5 months ago

def1149 commented 6 months ago

The problem

As of HA 2024.2.0b8 the battery % level reported by the integration for my Wave+ is still wrong. The Airthings App reports 22% and the intgegration reports 4%.

Is this transfer function so complicated that we're going to need to get rocket scientists involved?

What version of Home Assistant Core has the issue?

2024.2.0b8

What was the last working version of Home Assistant Core?

??

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Airthings BLE

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 6 months ago

Hey there @vincegio, @lastrada, mind taking a look at this issue as it has been labeled with an integration (airthings_ble) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `airthings_ble` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign airthings_ble` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


airthings_ble documentation airthings_ble source (message by IssueLinks)

def1149 commented 6 months ago

Installed HA 2024.2.0 and the Battery level IS STILL BOGUS. Sigh ...

def1149 commented 6 months ago

HA 2024.2.1 and Battery level for Wave+ is still bogus image

def1149 commented 6 months ago

Updated HA core to 2024.2.2 and battery percentage is STILL bogus. Will this ever be fixed?

def1149 commented 6 months ago

My Wave Plus is still running on its miracle battery with 0% life left

ismarslomic commented 5 months ago

I have also experienced difference in battery level reporting in HA (through the airthings_ble integration) compared with the Airthings Wave mobile app.

App is reporting 100% battery (its just three weeks since I changed batteries) and HA reports 80%. This has been an issue for more than 6 months (or more). I got Wave Plus device.

def1149 commented 5 months ago

It looks like the % available is running about 18-20% low. Be interesting if others are seeing the same offset. May need to create a template sensor to fix if the integration can't be fixed. If we had the raw voltage we could create our own voltage to % algorithm. It's not that complicated. We could also model the discharge curves for primary lithium cells, rechargeable lithium cells, and alkaline cells to be accurate assuming the voltage measurements are accurate. but that could be verified with raw voltage values. But the battery gauge doesn't need to be highly accurate, just better than being low 20% off to prevent replacing batteries that are fine

andrewlow commented 5 months ago

I too have an AirThings+ using BLE integration into HomeAssistant and see incorrect battery information.

I seem to have zero as the answer for the last 2 weeks of data.. The AirThings app tells me 72%

def1149 commented 5 months ago

Updated HA core to 2024.2.4 and battery percentage is STILL bogus.

ismarslomic commented 5 months ago

@def1149 any reason you expected it to be fixed in 2024.2.4? Release note did not mention any changes in the airthings_ble integration.

def1149 commented 5 months ago

@def1149 any reason you expected it to be fixed in 2024.2.4? Release note did not mention any changes in the airthings_ble integration.

This battery issue, one of several defects that I have reported in this integration, has been ongoing since at least September 2023 when I reported it on #100521, That's 5 months to fix a simple calculation. Is there a scheduled date to release the fix which was referenced in #110866 as fixed "a while ago"

joostlek commented 5 months ago

Feel free to help out fixing this "simple calculation". If you can't, please have patience and help out where needed.

def1149 commented 5 months ago

Feel free to help out fixing this "simple calculation". If you can't, please have patience and help out where needed.

I'm happy to be of assistance '

It's not known what Vmin and Vmax are for the Wave Plus but for Alkaline batteries the following simple formula won't be 20% off like the current "algorithm". Given that the batteries are supposed to last up to 18 months, the average discharge rate is very low. Also given these are indoor devices so batteries aren't typically exposed to low temperatures

Battery percentage = ((Current voltage - Vmin)/(Vmax - Vmin)) x 100

This can be further refined and made a little more accurate by breaking the discharge curve into a series of 6 or 8 segments and applying the same formula for each segment. Ultimately the accuracy of this depends on the accuracy of the A/D converter being used and that is also unknown without a device teardown and examination. My guess is that the A/D converter is not off by 20%

I could disassemble the device and measure the voltage and deduce Vmin and Vmax. But since the raw voltage isn't supplied by the integration I can't create my own template sensor to calculate the correct battery capacity remaining, or I would have already done that.

LaStrada commented 5 months ago

As I’ve said many times now, this is fixed here: https://github.com/Airthings/airthings-ble/pull/27

We haven’t made a release with this yet, but will very soon. We need to fix the light sensor (currently broken/missing) + test everything.

I will make a PR to fix the light sensor before the weekend, and I’m hoping for a release very soon after that so we can bump the framework in Home Assistant. I can promise this will be done in March, but cannot promise it will be part of 2024.3.0.

ismarslomic commented 5 months ago

@LaStrada thanks for clarifying. Is the fix for battery state dependent on the light sensor? If not, would it be possible to fix these two in different releases?