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
72.21k stars 30.23k forks source link

Xiaomi BLE missing battery sensor #111139

Open chemelli74 opened 7 months ago

chemelli74 commented 7 months ago

The problem

Xiaomi BLE doesn't create battery sensor for HHCCJCY01 devices. All other sensors are created and working properly:

image

What version of Home Assistant Core has the issue?

2024.2.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Xiaomi BLE

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_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 7 months ago

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` Renames 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. - `@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)


xiaomi_ble documentation xiaomi_ble source (message by IssueLinks)

Jc2k commented 7 months ago

How long have you had that sensor? If longer than a few days, can I see the graph for signal quality and can you confirm there are no logs from the integration?

For whatever reason, that sensor does not broadcast battery information.

There is a battery sensor that it tries to poll once a day only (as the sensor is not only usually incorrect, but polling it uses a lot of battery). However polling requires a much stronger signal. I'd expect -83 to be a little bit unreliable with this sensor. I would expect to see something in the logs if the poll failed. If nothing in the logs, check again in 24h.

chemelli74 commented 7 months ago

HI, thx for the quick reply.

Device is there since a week (others devices for even more). I can immagine signal strength is not good, but I would expect it to be at least created. If it needs a minimum strength for a long timeframe, I suggest to add this info to the documentation.

Ernst79 commented 7 months ago

Xiaomi BLE integration only creates a battery sensor if it receives the actual battery data. So it can take 24 h, and, as said by @Jc2k, battery data is only collected by connecting to the device (which is done once a day), and requires a good connection. All other data (temperature, etc) is received passively, and is broadcasted at a frequent interval (once per minute).

chemelli74 commented 7 months ago

Yup, I know the difference between actie and passive, but what is missing in the equation is "requires a good connection". Something like: "it needs at least -60 dBm for at least 60 minutes around 11pm" would help ;-)

WebfinityDesign commented 7 months ago

I can confirm the battery sensor is gone. I have 2 of these sensors for more than a year. The battery sensor never gave any problem but now it is gone. I tried to delete and add the sensors again but that didn't help. I have them laying next to the Bluetooth dongle (about 20 cm) for more than a week. Signal strength about -60dBm.

chemelli74 commented 5 months ago

Hi, can you at least add some debug log lines to help understanding why that sensor is no more created ? Thank you in advance

chemelli74 commented 3 months ago

Hi,

I think there is something to be fixed somewhere in the code path, as using esphome with myhomeiot_ble_client works perfectly. I see both firmware and battery status.

Jc2k commented 3 months ago

FWIW, still works fine here.

Screenshot 2024-06-21 at 15 19 10 Screenshot 2024-06-21 at 15 19 46
amzaldua commented 2 months ago

My battery level is three, but it always shows 100%. It never changes.

Neocray commented 2 months ago

I have two HHCCJCY01 devices since April and the battery sensor never showed up. image