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
73.07k stars 30.56k forks source link

yalexs_ble: inconsistant battery updates when "always connected" is on #120118

Open vin100ross opened 4 months ago

vin100ross commented 4 months ago

The problem

While investigating excessive battery drain on my Yale Assure 2 Touch lock (probably unrelated to this integration), I noticed that the battery status (voltage, percent) does not update consistently when the "always connected" option is on. It can sometimes take hours or even days to update, often only when I restart the integration or core. Upon disabling the "always connected" option, updates occur about every minute. I have repeated the test several times over the last few months with the same result.

Calling homeassistant.update_entity on the battery voltage sensor makes no difference.

Below is a graph of the battery voltage showing the issue:

image

I must note that the excessive battery drain does suggest that I have a defective lock (I have a ticket open with Yale). It is therefore possible that the lock itself is responsible for the problem, but I have no way to test this. It is strange that the battery would update normally with "always connected" off, however.

Also, I use an m5 Atom Lite Bluetooth proxy a few feet from the lock. The connection seems stable, and all other events (look, door) are almost instantaneous when "always connected" is on.

What version of Home Assistant Core has the issue?

core-2024.6.2

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

Yale Access Bluetooth

Link to integration documentation on our website

https://www.home-assistant.io/integrations/yalexs_ble

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Nothing special in the logs, even with debug logging activated.

Additional information

No response

home-assistant[bot] commented 4 months ago

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

Code owner commands Code owners of `yalexs_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 yalexs_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)


yalexs_ble documentation yalexs_ble source (message by IssueLinks)

vin100ross commented 3 months ago

I got a new lock under warranty from Yale a couple weeks back and I have been testing this further. I can confirm that I observe the same behavior, with battery state not updating or updating very inconsistently when "always connected" is on. So the old, defective lock was not at fault. All other sensors update almost instantly and consistently.

This is not a game-changer, but can be problematic, especially when the battery starts to get low.

bdraco commented 3 months ago

The library doesn't poll the battery when always connected mode is on https://github.com/bdraco/yalexs-ble/blob/6c97cc8a2c9b4e69903bea5e1a1a2b0cd74655ca/src/yalexs_ble/push.py#L715

Doing so seemed to crash the lock and require a physical reset (battery pull) so this is unlikely to get changed unless yale fixes the firmware

vin100ross commented 3 months ago

Ok, thanks.

Since the battery seems to update when connecting/reconnecting, a periodic "force reconnect", would probably patch the issue until the upstream issue is resolved. Since the battery drains very slowly on a healthy lock, reconnecting once every 24h (at night?) would probably suffice and have negligible effects.

I understand that this is mostly an upstream problem, so feel free to close this as "not planned" if you don't intend to implement a patch like the one I suggest.

Thanks for the great work!

bdraco commented 3 months ago

We can leave it open. It might eventually get fixed in the firmware and than I can go back and adjust the library. TBH, it might be a long long time before that happens though.