Integrating Xiaomi Mi Scale

I have a bluetooth dongle on my HA server. The scale seems to hold the last weight info for about 5 min so I have a cron job that runs every 5 min and calls the script.
The script connects to the scale and gets the latest reading and then sends the data to HA over MQTT

You first need to retrieve the MAC address of your scale: sudo hcitool lescan (step on the scale just before to wake it up) and enter it here instead of REDACTED: MISCALE_MAC = 'REDACTED'

Right I see thanks for that.

Other than weight what else can the script record from the scale?

it returns a data that appears to be impedance but no idea how Xiaomi uses that data to compute other measures so for now I compute BMI in HA

Oh right I see…

I was hoping there would be a way to get body fat percentage etc

well if you manage to find the formula to retrieve it from the impedance, please let me know.
In the meantime, BMI is weight / (height * height) where weight is in Kg and height is in m.

1 Like

Hi,

I’ve got mine working with Hassio by linking the mi fit app to google fit and then getting the data using the google fit custom component.

It’s a workaround, but it works and updates fairly quickly.

Thanks!

2 Likes

Does that give you body fat percentage too ?

My scale only gives out weight data so I’m not sure, but I don’t think so.

I got this python script from the Openhab comunity that includes the xiaomi data, from version 2 of the scale:


i’ve just started using HASS, is there a way to execute a python script easily on HASSIO?

Hi,

i tried using the miscale node in node-red on my hassos running on tinker board. but am getting the following error
Error: Cannot find module 'bluetooth-hci-socket
any one having gone through this? or knows a solution?
i couldnt find a node to install matching this. and dont know how to install it externally in HASSIO.

@lolouk44 is this (script) utilized for just 1 person using the scale? or it can record more than 1 person?

Hi @bachoo786

The same script is used for 3 persons. Weights are different enough that I know which person it is based on the weight alone
Here is the script I use
https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Xiaomi_Scale.py

2 Likes

This script is for version 1 of the script right?
Do you cron run this at different intervals or how do you handle the readings?

Hi @Brian_Mollegaard_Ped
Not sure what you mean with

The script it triggered via a cron job indeed that runs every 5 min. This is often enough that the scale doesn’t go into sleep mode, yet not that often that it drains the battery, which I’m really impressed with:
I’ve had the scale for about a year now. I weigh myself once a day and I’ve not had the replace the batteries yet.
Compared to my previous Salter non smart scale that drained its battery within 4 month with no use, it’s quite a change…

Hi @lolouk44
There is at least two versions of the scale, v. 1 measures only weight while v.2 adds fat %, water % and other measurements. I have been thinking about putting a xiaomi vibration sensor on the scale, instead but it seem a bit overkill. :slight_smile:

The script works with both v1 and v2 scales. With v2 it sends the body impedance, though I’ve not yet figured out the formula that xiaomi uses to calculate other body measurements.
I personally use this one to figure out the bmi
image https://www.organicnutrition.co.uk/images/body-mass-index-formula.jpg

The script I posted does some calcualtions, or you might want to have a look at the openscale app for android, its open source, taken that you know how to read code better than I do :wink:

If there a way to do this directly from hass? I’m using HASSIO and im quit new to the platform, and I didn’t figure out how to ssh into root yet… (or I might have lost the login and password)

I think this is a none hass component that controls your bluetooth:


I think you need to ssh into your pi and install it with root, which i don’t know how to do in the hasso platform

Tried a few times looking for a possible formula embedded in the code with no luck. Online available formulas done give me the same readings as the Xiaomi app so ended up with the above.