ble_monitor icon indicating copy to clipboard operation
ble_monitor copied to clipboard

[Bug]: Broken decimal precision in sensor states

Open szymucha94 opened this issue 1 year ago • 9 comments

What happened?

I'm using 4 x86 tablets acting as BLE relays. They don't modify packets - just putting exact string from hcidump and sending it to HA restapi. Some time ago (not sure when - can't state exact versions) battery % decimal precision broke. See attached picture. Not sure if relaying ble packets makes any difference here, but this issue is not exclusive to xiaomi devices. Changing precision in HA sensor information doesn't fix this. Currently using v12.7.2 as v12.8.0 doesn't want to start on HA core v2023.11.2.

Example curl call: curl -s -o /dev/null -X POST -H "Authorization: Bearer XXX"
-H "Content-Type: application/json"
-d '{"packet": "'"$hci_packet"'"}'
http://XXX:8123/api/services/ble_monitor/parse_data

412

Sensor type

No response

Relevant log output

No response

szymucha94 avatar Jan 07 '24 22:01 szymucha94

I experience this too, typically for sensors that report with high frequency.

kép

gya352 avatar Jan 07 '24 23:01 gya352

I also see the behavior. I'll look into it, it is not as obvious as adding a round function, so have to dig a bit deeper

Ernst79 avatar Jan 20 '24 17:01 Ernst79

Note to myself. I see similar behavior in the official xiaomi-ble integration. Looks like some bug in HA itself?

image

Ernst79 avatar Jan 24 '24 07:01 Ernst79

I think this issue is related to a HA frontend bug, see this issue

https://github.com/home-assistant/frontend/issues/18982

Ernst79 avatar Jan 24 '24 07:01 Ernst79

Same to me. I have problem with one BLE Xiaomi temperature sensor. But strange things is that only one sensor (with ATC custom firmware) have this issue, others sensors works fine. Problems started after upgrade Passive BLE Monitor version. image

stochlinski avatar Jan 24 '24 08:01 stochlinski

I think this issue is related to a HA frontend bug, see this issue

home-assistant/frontend#18982

Are you sure? Because only passive ble monitor sensors have this issue. I've got 400+ numerical sensors from z2m and none of these ever show such issue. Same applies to custom, rest-api created sensors that are updated every 5-10 seconds with same or similar values.

szymucha94 avatar Jan 24 '24 08:01 szymucha94

Not 100% sure, but I see the same behavior in the xiaomi-ble integration, see my previous screenshot and this one

image

This is NOT from the BLE monitor integration, but from Xiaomi-BLE.

Moreover, I tried all kinds of rounding in the code to fix it, but none of them seems to do anything. That is why I think the issue is related to the frontend issue. Lets see if the frontend issue is fixed, if the problem in BLE monitor is also fixed, because I don't have any clue where the issue can be, otherwise.

Ernst79 avatar Jan 24 '24 08:01 Ernst79

The problem does not only affect xiami sensors, I have a similar problem with Goove and Jaalee sensors as well.

gya352 avatar Jan 24 '24 08:01 gya352

I know, with Xiaomi-BLE, I was referring to the official Xiaomi-BLE HA integration, which also shows this behavior. And also ZHA zigbee sensors show this behavior, according to this issue

Ernst79 avatar Jan 24 '24 09:01 Ernst79