custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.89k stars 243 forks source link

[Bug]: MiScale V2 catty/jin units #1095

Closed x11x closed 1 year ago

x11x commented 1 year ago

What happened?

On my scale (Xiaomi Mi Body Composition 2), catty units is indicated by the 6th bit of the control byte being on (so in your code control_byte & (1 << 6) instead of measunit & (1 << 4) (miscale.py line 45].

I have not tested on other models, but I believe Mi Scale 2, etc. (all "V2" models) are the same.

I have not actually run your code (that's why I didn't make a PR), I just found this in my own testing with the device.

I have seen other sources found the same thing:

However, I have also noticed many other apps/libraries don't even detect catty units for V2 scales (e.g. https://github.com/esphome/esphome, https://github.com/lolouk44/xiaomi_mi_scale), not sure why. Either because nobody is using catty units (I don't either, I just noticed this while testing different units). Or there is some discrepancy between models or difficulty detecting it.

EDIT: my mistake, oliexdev/openScale actually is detecting catty units the same way as I described above (6th bit of control byte 1), however that code seems to have a bug where they are also using the 6th bit as "isDateInvalid", which has an open bug report

Sensor type

MiScale V2

Relevant log output

No response

Ernst79 commented 1 year ago

Thanks for this in depth investigation!!!

I've fixed it in #1096. I don't think someone actually uses this unit (at least, nobody has complained). Fix will be included in the next release.