Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaomi_ble reports battery status as unavailable #82168

Closed
austin202220 opened this issue Nov 15, 2022 · 14 comments
Closed

Xiaomi_ble reports battery status as unavailable #82168

austin202220 opened this issue Nov 15, 2022 · 14 comments

Comments

@austin202220
Copy link

The problem

The integration as I understand it required active BT connection to pull battery level, so it only pulls this once per day to save battery. The problem is that after a couple of hours the integration reports to HA that battery level is Unavailable.

Need the battery level to not be marked unavailable until after lets say 48 hours or so.

I have tried with and without BT proxies. Tried ESPHome v10.2, and V11.b04

What version of Home Assistant Core has the issue?

11.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

Xiaomi 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
Copy link

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

Code owner commands

Code owners of xiaomi_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 reopen Reopen the issue.
  • @home-assistant unassign xiaomi_ble Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


xiaomi_ble documentation
xiaomi_ble source
(message by IssueLinks)

@Ernst79
Copy link
Contributor

Ernst79 commented Nov 16, 2022

what device do you have?, Battery polling is only done for the plant sensor

@Jc2k
Copy link
Member

Jc2k commented Nov 16, 2022

I don't see this with my plant sensor, so there must be an environmental factor. Could you turn the signal strength sensor on for your plant sensor and let me see what it looks like. Or maybe post a picture of your temperature graph when the battery is unavailable for a while?

@austin202220
Copy link
Author

I have about 40 of the plant sensors. I have both the small versions, HHCCJCY01, and also the larger ones (GCLS002). Temperature and illuminance values are updating very often, no issue there, its just the battery levels.

All sensors are within 10 feet of an esphome esp32 bluetooth proxy module.

I am turning on the signal strength for a few of the sensors now, I will report back after it has had some time to collect data.

Screen Shot 2022-11-17 at 11 22 49 AM

Screen Shot 2022-11-17 at 11 24 07 AM

@austin202220
Copy link
Author

A few more screenshots, the 3rd one shows the spotty battery readings in combination with the moisture, as you can see it just the battery reading that is spotty

Screen Shot 2022-11-17 at 11 37 16 AM

Screen Shot 2022-11-17 at 11 34 34 AM

Screen Shot 2022-11-17 at 11 29 34 AM

@austin202220
Copy link
Author

So its getting battery readings here and there, just need to extend the amount of time it takes before the battery entity is reported to be unavailable. The warning it get is

"This entity is no longer being provided by the xiaomi_ble integration. If the entity is no longer in use, delete it in settings."

@austin202220
Copy link
Author

Also maybe a feature request for this integration? Currently I add in a helper each time I set up a new plant sensor to calculate the total light the plant receives each day. The illuminance sensor just gives instantaneous readings. Maybe you could write this into the integration?

Screen Shot 2022-11-17 at 11 45 02 AM

Screen Shot 2022-11-17 at 11 44 40 AM

@Jc2k
Copy link
Member

Jc2k commented Nov 17, 2022

There are 2 types of unavailability.

A device can disappear from the Bluetooth stack and become unavailable. This isn't driven by timers as such - there is a timer that drives checking in with the Bluetooth stack, but it's up to bluez stack to decide what is and isn't available. If it's not available in bluez it really isn't, you can't even try to connect to it. (AIUI the esp code works the same).

This isn't helpful for advertisement driven stuff with slow advertisement intervals - they can literally turn their radios off for hours. So there is a second self calibrating mechanism that tracks the time between broadcasts for each mac. So if a device broadcasts every 2 hours then we'd only mark it unavailable if we haven't heard from it at least 2 and a bit hours. But the device that broadcasts every 10s can be marked unavailable after a minute.

I don't know which of these applies to the plant sensor battery (forgot what I did, and on phone right now), but neither of them should be kicking in if your HA is receiving advertisements and the sensor is within connectable range of an esp proxy. And your graphs give the impression that that's all in order.

@Jc2k
Copy link
Member

Jc2k commented Nov 17, 2022

This entity is no longer being provided by the xiaomi_ble integration. If the entity is no longer in use, delete it in settings.

This happens when you restart HA and there has been no successful poll since the restart and that's expected.

@Jc2k
Copy link
Member

Jc2k commented Nov 17, 2022

Interesting feature request, would probably want an arch issue before I'd pick it up, unless there are already a couple of illuminance sensor doing something similar in other core integrations.

@peterjuras
Copy link

Hi,
I'm also seeing the issue only with the battery sensor. It stopped working some time ago and now stays as "restored" without any new readings since a while. All other sensors (temperature, illuminance etc.) are working correctly.

I have this sensor: https://esphome.io/components/sensor/xiaomi_ble.html#hhccjcy01

@peterjuras
Copy link

Battery status is working for me again either since 2022.12.5 or 2022.12.6.

@hobbypunk90
Copy link
Contributor

I have the same problem on HA 2023.2.5 with my sensors, some battery data are gathered, but hours ago, all other sensor data are seconds or minutes old 🙈

@issue-triage-workflows
Copy link

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.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants