custom-components / ble_monitor

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

[New Sensor]: mi scale XMTZC02HM not showed up in HA #1071

Closed Smandurlo closed 1 year ago

Smandurlo commented 1 year ago

Sensor Description

body scale

Additional information

I am using the HA bluetooth integration, not the BLE monitor addon. According with the documentation, it should be already moved to HA bluetooth integration, but the XMTZC02HM doesn't show up. I was not able to collect the BLE advertisement with the Home Assistant logger (since the bluetooth integration doesn't have the option to), so I use the HCIdump way.

Debian 11 with Plugable USB-BT4LE (BCM20702A0), bluez 5.66 with experimental and passive mode

Screenshot_2022-12-19-14-22-28-056_com xiaomi hm health

BLE advertisements

HCI sniffer - Bluetooth packet analyzer ver 5.55
device: hci0 snap_len: 1500 filter: 0x2
< 01 0C 20 02 00 00 
> 04 0E 04 01 0C 20 00 
< 01 0B 20 07 00 60 00 30 00 00 00 
> 04 0E 04 01 0B 20 00 
< 01 0C 20 02 01 01 
> 04 0E 04 01 0C 20 00 
> 04 3E 24 02 01 00 01 B1 22 51 0B C1 DD 18 02 01 06 03 02 1B 
  18 10 16 1B 18 02 A6 E6 07 0C 13 0D 10 1C 5E 02 50 37 BC 
> 04 3E 2B 02 01 03 01 B8 E1 FC 9A 52 79 1F 1E FF 06 00 01 09 
  20 02 2B 0E 10 66 21 C8 7F 41 21 51 4A B9 5F FB B4 89 31 ED 
  0E CA CA 2F F6 BC 
> 04 3E 2B 02 01 00 00 7B 81 AA 09 5E CA 1F 02 01 06 1B FF 57 
  01 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 02 CA 
  5E 09 AA 81 7B BA 
> 04 3E 28 02 01 02 01 3E 2A FF FE 5B 50 1C 03 03 9F FE 17 16 
  9F FE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 AA 
> 04 3E 29 02 01 00 00 27 4D 6A 8D 7C C4 1D 02 01 06 03 02 95 
  FE 15 16 95 FE 71 20 98 00 32 27 4D 6A 8D 7C C4 0D 07 10 03 
  F8 00 00 BC 
> 04 3E 2B 02 01 00 00 47 E4 95 BD 8A 80 1F 02 01 1A 1B FF 75 
  00 42 04 01 01 67 80 8A BD 95 E4 47 82 8A BD 95 E4 46 06 00 
  00 00 00 00 00 A0
Ernst79 commented 1 year ago

First checks (Work in Progress).

Message from scale 04 3E 24 02 01 00 01 B1 22 51 0B C1 DD 18 02 01 06 03 02 1B 18 10 16 1B 18 02 A6 E6 07 0C 13 0D 10 1C 5E 02 50 37 BC

Result with my local testing parser {'non-stabilized weight': 70.8, 'weight unit': 'kg', 'weight removed': 1, 'stabilized': 1, 'type': 'Mi Scale V2', 'firmware': 'Mi Scale V2', 'mac': 'DDC10B5122B1', 'packet': '02a6e6070c130d101c5e025037', 'rssi': -68, 'data': True}

So, the parser should be fine.

Next step, testing why this doesn't show up in HA

DigiH commented 1 year ago

Seems to be missing the impedance in the above parsed results, and not sure why 'stabilized': 1, but 'non-stabilized weight'. Could it be that non-stabilized is not being transferred to/registered in HA?

Just FYI 02a6e6070c130d101c5e025037 {"brand":"Xiaomi","model":"Mi_Body_Composition_Scale","model_id":"XMTZC02HM/XMTZC05HM","weighing_mode":"person","unit":"kg","weight":70.8,"impedance":606}

Smandurlo commented 1 year ago

I made other measurements. I waited till the end when the scale is done. I have no idea if and why the impedance is missing.

dump2.txt

EDIT: I checked with zepp life app and the app shows all the data (water, visceral fat, bmi and so on), so the impedance should be sent... Correct me if I am wrong

DigiH commented 1 year ago

I made other measurements. I waited till the end when the scale is done. I have no idea if and why the impedance is missing.

I checked with zepp life app and the app shows all the data (water, visceral fat, bmi and so on), so the impedance should be sent... Correct me if I am wrong

No worries, nothing you did wrong. Was more for @Ernst79 as the parser needs to be adjusted to allow for the impedance to also be recognised.

Ernst79 commented 1 year ago

ah, sorry @Smandurlo I totally missed this part of your question:

According with the documentation, it should be already moved to HA bluetooth integration, but the XMTZC02HM doesn't show up.

I thought it didn't work in BLE monitor, but you meant in the HA xiaomi-ble integration, my mistake.

It is correct that it doesn't show up in the Xiaomi-ble integration, as the MiScales use a different UUID. In BLE monitor, a different parser is used for MiScale. Most Xiaomi sensors use the MiBeacon format, with UUID FE95, but the Xiaomi Scales use a different UUID and also have a different format to decode the data.

So, you will have to wait till the MiScale parser is converted to an official HA integration (or more likely, added to the Xiaomi-ble integration).

Smandurlo commented 1 year ago

Wait, I am a bit lost... BLE monitor is your HACS integration and it is moving to HA Bluetooth integration, isn't it? What is Xiaomi-ble integration now? How should I use all my xiaomi sensors (plant and thermometer) and miscale with the new Bluetooth HA mesh?

I am sorry, I am a bit confused

Ernst79 commented 1 year ago

Wait, I am a bit lost

No problem, I'll try to explain.

BLE monitor is your HACS integration and it is moving to HA Bluetooth integration, isn't it? What is Xiaomi-ble integration now?

Almost correct.

We did this move for (a large part of) the Xiaomi sensors that use the MiBeacon BLE format. However, we did not make the move yet for Xiaomi MiScale sensors (scales), as this is a different format.

The more detailed explanation,

The last (MiScale) isn't done yet. Most likely, I will add that to the xiaomi-ble integration, such that you won't notice it as a user, that it is using a different format.

Hopefully, this makes it a bit more clear. If not, let me know.

Smandurlo commented 1 year ago

Yes, very crystal clear now! Thank you very much :-) I will wait you move everything I would like to use into an official HA integration so I can use the Bluetooth mesh. I can survive without the scale 😂 thank you for your great work