ble_monitor icon indicating copy to clipboard operation
ble_monitor copied to clipboard

[New Sensor]: Amazfit Smart Scale

Open Mosher23 opened this issue 2 years ago • 5 comments

Sensor Description

Amazfit Smart Scale

Additional information

Hello,

is it possible to add this sensor? https://www.amazfit.com/de/amazfit-smart-scale.html It is possible to see MAC-adress in the app.

thank you in advance

BLE advertisements

2022-06-29 09:27:48 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc80000000000000000001f0201060302e0fe1716e0fe0a80e6c778a37900000000000000000000000000
2022-06-29 09:27:48 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc80000000000000000001f0201060302e0fe1716e0fe0a00e6c7fab3d9aa410000000000000000000000

Mosher23 avatar Jun 29 '22 07:06 Mosher23

Some first analysis

1716e0fe0a80e6c778a37900000000000000000000000000 1716e0fe0a00e6c7fab3d9aa410000000000000000000000

17 = length 16 = uuid e0fe = manufacturer id 0a80e6c778a3790000 = data message 1 0a00e6c7fab3d9aa41 = data message 2

Can you make a longer log, preferably with some reported values like weight, etc. Whatever the app is reporting. This will help me comparing the numbers with actual measured data.

Ernst79 avatar Jun 30 '22 12:06 Ernst79

Hi,

i have genereted more log.

so It showed me on the weight following information: weight: 85,3 kg weight increase: 6,7 kg fat: 26,3% heartbeat: 104bpm BMI: 26,3 muscles: 59,7kg water: 50,5% some other fat i guess: 23,4%

Hope it helps

2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbb0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbe0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbf0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc10000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbe0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:58 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc10000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc10000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc10000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fba0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fb80000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbe0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fbf0000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:01:59 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fc20000000000000000001f0201060302e0fe1716e0fe8a83e6c7fc8367c62a0000000000ffffffffffff
2022-06-30 21:08:30 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fb10000000000000000001f0201050302e0fe1716e0feba82e6c7fc3414a442bf46ec68000462bba30100
2022-06-30 21:08:32 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fb00000000000000000001f0201050302e0fe1716e0feba82e6c7fc3414a442bf46ec68000462bba30100
2022-06-30 21:08:33 INFO (Thread-3) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 70879e30a40e: 043e390d011300000ea4309e87700100ff7fb10000000000000000001f0201050302e0fe1716e0feba82e6c7fc3414a442bf46ec68000462bba30100

Mosher23 avatar Jun 30 '22 19:06 Mosher23

Hmmm. Can't make much sense out the the data. I tried to reproduce some measurement with a hex to dec converter, but I don't see an obvious relation between the data and the measurements. So, they probably have some complicated formula to decode the data.

I copied the relevant data below, trying to find a relation. Most often, a measurement is 1 or 2 bytes long. Looking at the data, I suspect that they use big endian (= read the data from left to right), but not 100% sure.

ba82 e6c7 fc34 14a442 bf46ec68000462bba30100
ba82 e6c7 fc34 14a442 bf46ec68000462bba30100
ba82 e6c7 fc34 14a442 bf46ec68000462bba30100
0a80 e6c7 78a3 790000 0000000000000000000000
0a00 e6c7 fab3 d9aa41 0000000000000000000000
8a83 e6c7 fc83 67c62a 0000000000ffffffffffff

Ernst79 avatar Jul 01 '22 12:07 Ernst79

Hi,

Using the first data line as an example: ba:82:e6:c7:fc:34:14:a4:42:bf:46:ec:68:00:04:62:bb:a3:01:00

#0-#6 byte - I dont know...#2-#6 maybe the timestamp #7-#8 byte, weight: a4 42 => 8bitU8 = 164 66 => left shift => ((log(66 << 8)) +164) / 200 = (16896 + 164) / 200 = 85,3kg #12 byte, pulse: 68 => 8bitU8 = 104 #14-#19 byte, user informations. If it is zero all the way, then identification has not taken place.

The first 3 data rows are identical, the 4th and the last: no measurements were made, the 5th: 84,05kg and only weight was measured. I'm glad if I could help, I also want to extract the impedance, I did a lot of research but gave up.

machinev1 avatar Aug 10 '22 21:08 machinev1

Thanks for this info! Will add it in a couple of days.

Ernst79 avatar Aug 11 '22 06:08 Ernst79

Sorry, it took so long, I forgot to finish this. I just released 10.7.0-beta could you give it a try?

I use byte 9-11 to say if it is stabilized or not. If byte 9-11 are all 00, than it is not stabilized, otherwise, it is stabilized and it will report weight and pulse.

Can you please verify that it works as expected? And please also check if a pulse sensor is created.

Ernst79 avatar Nov 18 '22 15:11 Ernst79

I also want to extract the impedance, I did a lot of research but gave up.

Could #5-#6 / 10 be the impedance?

ba82 e6c7 fc 3414 a442 bf46ec68000462bba30100 ba82 e6c7 fc 3414 a442 bf46ec68000462bba30100 ba82 e6c7 fc 3414 a442 bf46ec68000462bba30100

3414 little endian = 5172 / 10 = 517.2 Ω

Would need additional height etc. to see if that might fit for calculating the other values like bmi, muscles, fat …

DigiH avatar Nov 18 '22 18:11 DigiH

I don't have the scale myself, so I have to rely on you guys for testing. I can add impedance, if you think this is correct.

BTW. This integration can calculate all the other values for you, like BMI.

Ernst79 avatar Nov 18 '22 19:11 Ernst79

I don't have it either, but impedance is usually the only other property transmitted for then calculating all the other values like bmi, muscle percentage, fat etc. when the gender, age and height are taken into account as well.

Yes, as your linked example for the Xiaomi Mi Body Composition Scale shows.

So @Mosher23 could see if an impedance value of 517.2 Ω would fit with gender, height and age, following the above linked calculations to get similar results for

fat: 26,3% BMI: 26,3 muscles: 59,7kg water: 50,5% some other fat i guess: 23,4%

DigiH avatar Nov 18 '22 19:11 DigiH

I have added the impedance to 10.7.1-beta. Lets just give it a try and let me know if the impedance makes sense.

Ernst79 avatar Nov 18 '22 19:11 Ernst79

I will test it tomorrow/after tomorrow and give feedback here. Thank you in advance

Mosher23 avatar Nov 18 '22 19:11 Mosher23

did you had a change to test it?

Ernst79 avatar Nov 22 '22 07:11 Ernst79

Unfortunately, not yet. Unexpected hospital stay. Will do after I return home.

Mosher23 avatar Nov 22 '22 07:11 Mosher23

Take your time. There are more important things that testing scales. Get well soon.

Ernst79 avatar Nov 22 '22 07:11 Ernst79

Did you had a change to have a look if it works?

Ernst79 avatar Dec 11 '22 19:12 Ernst79

Did you had a change to have a look if it works?

Hi, Finally have I had a chance to test it. No success at all. I have tried it paired with the Zepp App and unpaired. With and without BMI. After the measurement no new devices is added to integration. Even I can see data in the app.

Mosher23 avatar Dec 17 '22 17:12 Mosher23

Did you test with 10.7.1-beta. The more recent beta's do not have Amazfit support, only 10.7.1-beta. So install that specific version to try

Ernst79 avatar Dec 17 '22 17:12 Ernst79

I have tested to day with 10.7.1-beta. First time integration read single value which was 4kg of form the actual reading on the scale. I redid the measurement like 20 times but the initial measurement didn't change. Screenshot 2022-12-18 at 10 06 09

Mosher23 avatar Dec 18 '22 09:12 Mosher23

Strange. Didn't you get the "weight", "impedance" and "pulse" sensor? I only see the non-stabilized weight sensor in your print screen. Any errors in the logs?

Ernst79 avatar Dec 18 '22 09:12 Ernst79

everything you see on the image is all i got.

Here is an error log: `This error originated from a custom integration.

Logger: homeassistant Source: custom_components/ble_monitor/sensor.py:941 Integration: Passive BLE monitor (documentation, issues) First occurred: 09:58:23 (1 occurrences) Last logged: 09:58:23

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/ble_monitor/sensor.py", line 301, in async_run entity.collect(data, period_cnt, batt_attr) File "/config/custom_components/ble_monitor/sensor.py", line 941, in collect self._extra_state_attributes["stabilized"] = bool(data["stabilized"]) KeyError: 'stabilized' `

Mosher23 avatar Dec 18 '22 09:12 Mosher23

Thanks, I missed adding the stabilized parameter to the output, will create a new beta in a few minutes.

Ernst79 avatar Dec 18 '22 09:12 Ernst79

10.9.2-beta is ready for testing.

Ernst79 avatar Dec 18 '22 09:12 Ernst79

Nice! I can verify its working now! Even my scale shows some really off results. Sensor values in integration are exactly what scale shows.

Thank you so much! Screenshot 2022-12-18 at 10 46 11

Mosher23 avatar Dec 18 '22 09:12 Mosher23

Thanks for testing. Released as final version in 10.9.2.

Ernst79 avatar Dec 18 '22 10:12 Ernst79

Hi @Ernst79 and @Mosher23 not to dampen the integration, and admittedly not knowing too much about the general impedance values myself, the above value of 2321,8 Ohm seems very high to me, especially in the light of the previous raw data bytes give making me think that the the impedance could be 517,2 Ω.

@Mosher23 - Was this weighing done barefoot or with socks or shoes on? And was it the same person who had the assumed 517.2 previously?

What I thought would be the best way to verify if this is actually the impedance data, was to also install this integration, mentioned by Ernst above, to see if this assumed impedance value calculates the same BMI, muscles, fat etc. as the scale's own app.

Currently I think my assumption might have been wrong and the integration of it might show totally wrong impedance values and related calculations from it.

DigiH avatar Dec 18 '22 14:12 DigiH

I have programmed it as byte 5-6 in little endian --> divide by 10 --> impedance, based on the assumption of @Mosher23. Not sure if the app reports back impedance, but the app of the scale might also report back the impedance. Perhaps @Mosher23 can compare this. Let me know if I have to change something.

Ernst79 avatar Dec 18 '22 14:12 Ernst79

Actually I own also Xiaomi Composition Scale 2, they report impedance of 514Ohm. And yes I do remove socks before measurements.

Mosher23 avatar Dec 18 '22 15:12 Mosher23

@DigiH I have bodymiscale integration and it calculates much different values than Zepp app which scales are connected to

Mosher23 avatar Dec 18 '22 15:12 Mosher23

Actually I own also Xiaomi Composition Scale 2, they report impedance of 514Ohm.

So my initial assumption of 517,2 Ω wasn't far off, but the new 2321,8 is way wrong ;) so these two bytes might not be the Amazfit scale impedance after all.

DigiH avatar Dec 18 '22 15:12 DigiH

@DigiH I have bodymiscale integration and it calculates much different values than Zepp app which scales are connected to

I would possibly expect slightly different calculated values, as the Zepp app probably has a slightly different algorithm to calculate all the BMI, muscle, fat etc. values as the above linked to HA integration, but they shouldn't be very different.

Is that the case for both the Amazfit and Xiaomi Mi Body Composition scale?

DigiH avatar Dec 18 '22 15:12 DigiH