Integrating Xiaomi Mi Scale

Correct. So int((data[28:26] + data[26:28]), 16) * 0.01 is in jins.

I believe Mi Fit apk can be reverse engineered to find the formula.

I’m on iOS so can’t do this. If you have android and can reverser eng, that would be great

I can run android on a beaglebone however even Android Studio is not set up on any of my computers. APK is there: https://www.apkmirror.com/apk/anhui-huami-information-technology-co-ltd/mi-fit/mi-fit-3-4-0-1-release/

It can easily be disassembled and formula can be extracted.

great, I’ll wait for your feedback then :slight_smile:

Well, actually in https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale, it has been noted that “Only the weight are supported by openScale. The rest of the body metrics are currently not supported because of the not transparent impedance calculation by the company”.

The formulae in openscale are at https://github.com/oliexdev/openScale/wiki/Body-metric-estimations but these do not consider the resistance measured by the scale.

I was just wondering how often to run the script.
@syssi listed above a run on an hourly interval at xx:30. I’m concerned that the scale will be in sleep mode by then.
Yet if I refresh too often, the scale doesn’t go into sleep mode, thus consuming more power/battery
I was wondering if anyone had found a “sweet spot” on how often to “prod” the scale to check for readings to

  1. ensure the latest weighing gets caught
  2. ensure we don’t keep the scale “awake”

So far I’m running at a 5 min interval but would like to hear other people’s experience

I am thinking of creating a switch template which would run the script.
If I call it something like “Scale”, I would be able to command Alexa “turn on scale” after I weight myself, and this will read the data off the scale.

Everything is in future tense because I just got mi scale delivered and haven’t yet tried to use it :slight_smile:

I’ve been playing about with the “sleep” time for the script. It is now called by a cron job every 5 min. It’s enough to catch a reading before the scale goes back to sleep, and not often enough that it’ll keep it awake.

image

Now I’m no android user and have no idea on how to reverse engineer an apk, but if someone had the skills to try and extract the formulae used to calculate the various body measures, it would be great

I managed to download the APK and convert it to JAR, but I have no idea what or where to look to try and get he formula.
Is there anybody who’s familiar with APK / Android programming who could have a look or at least give me some pointers? I can PM the files if required.

I was playing with it as well, didn’t find anything unfortunately.
I believe the formula is somewhere in these ARM compiled files:
lib\armeabi\libBodyfat.so
lib\armeabi\libdataProcess.so
No idea how to decompile them though. I saw some ASM/C++ converters, but they are not free. ASM is simply gibberish to me so that I have no point of looking at even :slight_smile:
We need someone who can dig deeper!

1 Like

Guys, what about OpenScale?

I’ve done a feature request: OpenScale component

It’s been a while since I’ve started this post. Today I’ve taken the time to write a blog post about the way I’ve integrated the MiScale in Homeassistant. The post is in german. Maybe it’s helpful to someone.

https://www.triumvirat.org/2018/07/28/miscale-und-homeassistant/

2 Likes

interesting read. So you don’t do anything with the impedance I guess to calculate the BMI and only take your height into consideration?

Absolutely right. I’ve got the first version of the scale. It doesn’t have the impedance functionality.

The guy from OpenScale is close to make it work for BMI, Muscle, water, etc. It would be nice to integrate that into HA. With the new user features, it makes a lot of sense

Why do you think he’s close to make it work ?

Stupid question Alert:

When I’m trying to run this script (https://hastebin.com/mibikorepo.py) I’m getting the following error. What m’I doing wrong ?

/home/pi# sudo python ./miscale.py
Traceback (most recent call last):
File “./miscale.py”, line 9, in
from bluepy import btle
ImportError: No module named bluepy

Note: I have installed bluepy in the Pi 3B, and trying to execute the script home directory.

what version of python are you running?

Python 3.5.3