Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Sensor]: Amazfit Smart Scale #910

Closed
Mosher23 opened this issue Jun 29, 2022 · 33 comments
Closed

[New Sensor]: Amazfit Smart Scale #910

Mosher23 opened this issue Jun 29, 2022 · 33 comments
Assignees
Labels
new sensor Request for a new sensor

Comments

@Mosher23
Copy link

Mosher23 commented Jun 29, 2022

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 Mosher23 added the new sensor Request for a new sensor label Jun 29, 2022
@Ernst79
Copy link
Collaborator

Ernst79 commented Jun 30, 2022

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.

@Mosher23
Copy link
Author

Mosher23 commented Jun 30, 2022

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Jul 1, 2022

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 Ernst79 added the help wanted Extra attention is needed label Jul 1, 2022
@machinev1
Copy link

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.

@Ernst79
Copy link
Collaborator

Ernst79 commented Aug 11, 2022

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

@Ernst79 Ernst79 removed the help wanted Extra attention is needed label Aug 11, 2022
@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 18, 2022

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.

@DigiH
Copy link

DigiH commented Nov 18, 2022

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 …

@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 18, 2022

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.

@DigiH
Copy link

DigiH commented Nov 18, 2022

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%

@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 18, 2022

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.

@Mosher23
Copy link
Author

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 22, 2022

did you had a change to test it?

@Mosher23
Copy link
Author

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 22, 2022

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 11, 2022

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

@Mosher23
Copy link
Author

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.

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 17, 2022

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

@Mosher23
Copy link
Author

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 18, 2022

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?

@Mosher23
Copy link
Author

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'
`

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 18, 2022

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 18, 2022

10.9.2-beta is ready for testing.

@Mosher23
Copy link
Author

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

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 18, 2022

Thanks for testing. Released as final version in 10.9.2.

@Ernst79 Ernst79 closed this as completed Dec 18, 2022
@DigiH
Copy link

DigiH commented Dec 18, 2022

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.

@Ernst79
Copy link
Collaborator

Ernst79 commented Dec 18, 2022

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.

@Mosher23
Copy link
Author

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

@Mosher23
Copy link
Author

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

@DigiH
Copy link

DigiH commented Dec 18, 2022

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
Copy link

DigiH commented Dec 18, 2022

@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?

@Mosher23
Copy link
Author

Only for amazfit. It calculates basal age of my body as 80 years

@DigiH
Copy link

DigiH commented Dec 18, 2022

Or what could well be the case is that it is these two bytes, but they need to be masked by possibly & FFF, and then the remaining byte with its four bits actually indicating if the impedance recognition was correct, i.e. if the weighing was done barefoot and not with socks or shoes on, or something else.

Similar to the Xiaomi Mi Body composition scale, which always reports the impedance, but the values are only ok to integrate if the impedance applicable bit is set to true. If it is false the reported impedance values are way off becuse of not being barefoot, and should not be taken into account.

This would need a few more weighings reported with and without shoes giving the raw data, to see if there is a impedance applicable bit present in these bytes.

Only for amazfit. It calculates basal age of my body as 80 years

So definitely wrong in the latest case ;)

@DigiH
Copy link

DigiH commented Dec 19, 2022

The only way I could get close to the assumed 514 Ohm range was with < 1 &FFF.

Too far fetched I would say. So bytes 5-6 likely don't have anything to do with the impedance :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new sensor Request for a new sensor
Projects
None yet
Development

No branches or pull requests

4 participants