ble_monitor
ble_monitor copied to clipboard
[Bug]: Broken decimal precision in sensor states
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
Sensor type
No response
Relevant log output
No response
I experience this too, typically for sensors that report with high frequency.
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
Note to myself. I see similar behavior in the official xiaomi-ble integration. Looks like some bug in HA itself?
I think this issue is related to a HA frontend bug, see this issue
https://github.com/home-assistant/frontend/issues/18982
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.
I think this issue is related to a HA frontend bug, see this issue
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.
Not 100% sure, but I see the same behavior in the xiaomi-ble integration, see my previous screenshot and this one
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.
The problem does not only affect xiami sensors, I have a similar problem with Goove and Jaalee sensors as well.
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