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.46k stars 29.39k forks source link

battery shows 0% #81201

Closed Anto79-ops closed 1 year ago

Anto79-ops commented 1 year ago

The problem

Hi,

Awesome integration, thanks!

battery level shows 0% on my Airthings Wave Plus and error message below

Logger: homeassistant
Source: components/airthings/sensor.py:161
First occurred: 9:48:43 AM (7 occurrences)
Last logged: 10:25:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 669, in state
    value = self.native_value
  File "/usr/src/homeassistant/homeassistant/components/airthings/sensor.py", line 161, in native_value
    return self.coordinator.data[self._id].sensors[self.entity_description.key]
KeyError: 'battery'

What version of Home Assistant Core has the issue?

2022.11.0b2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Airthing BLE

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/airthings_ble

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 1 year ago

Hey there @vincegio, 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` Change the title of the issue. - `@home-assistant unassign airthings_ble` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


airthings_ble documentation airthings_ble source (message by IssueLinks)

Anto79-ops commented 1 year ago

I should mention, battery level as reported by the Airthings app is 19%.

Anto79-ops commented 1 year ago

just an update on this: I changed the batteries, in case 19% was too low, and refreshed the integration and all of sudden the battery level showed up at 100% and reporting.

the issue about the battery has been resolved, not sure what caused it in the first place.

vincegio commented 1 year ago

Hi, what kind of batteries did you use? To calculate battery level, we check the voltage range, might diff some depending on three battery I suspect.

Anto79-ops commented 1 year ago

Hi thanks for your reply, @vincegio

I have regular AA energizer Alkaline 1.5v batteries installed.

It's possible the algorithm could use a bit of tweaking for example I have three wave plus devices now in the integration the only one that is reporting correctly is the one with new batteries at 100%, however the other two devices are reporting around 30% less than what the Airthings app says.

mboisson commented 1 year ago

I can attest to the same thing with my own device. Battery level reported in Home Assistant are way off.

vincegio commented 1 year ago

I'll continue to play around with this and see if there should be any modifications to this default value: https://github.com/vincegio/airthings-ble/blob/543e804995b7e0e36ce15697c5f7dab1432caa57/airthings_ble/parser.py#L323 Range is currently at 2.4-3.2 volt.

cdnninja commented 1 year ago

I have the same thing. Air things is reporting 84% battery. Home assistant is reporting 0%.

cdnninja commented 1 year ago

Found this. I will work on trying to figure out how it reports this. https://help.airthings.com/en/articles/5326784-business-devices-battery-indicator If you have tips on viewing the raw becon data easily let me know.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.