Integrating Xiaomi Mi Scale

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.

Guess you could try an automation but I thick the issue with hass.io is it won’t run as root and I seem to remember that was a requirement

Thanks for the code, very helpful. Using it with MiScale v1.

There is a small syntax problem in line 67 when calling the self.publish function.
i had to replace
self._publish(round(measured, 2, "", ""), unit)
with
self._publish(round(measured, 2), unit, "", "")

So any chance the v1 can give datetime too? or atleast any identifier that can tell if the reading is same as the last one that we collected?

thanks alot for the help.

i finally gave up on nodered. Am now using Lolouk44’s script. Will use a button or something to trigger it when a family member weigh themselves. and need to calculate BMI for each one of us too

Can’t see why you can’t call the publish function again or add a parameter to give a timestamp

Have a look here: GitHub - wiecosystem/Bluetooth: Documentation of the Bluetooth/BLE devices
and especially here: https://github.com/wiecosystem/Bluetooth/blob/master/sandbox/body_metrics.py

It has all required forumlas :slight_smile:

1 Like

Any chance to get instruction to to setup this integration in Hass.IO ?

1 Like

Thanks that’s awesome. Will look into it and will incorporate when I get the time

1 Like

Are you sure this has anything to do with node red? I ran it though ssh when I used it.

Lolouk44, maybe i am confused. I meant datetime stamp from the scale itself. it seems you are getting it from V2 but not from V1. probably because v1 is not exposing it?

got it thanks. I only have the V2 scale so can’t check or otherwise test the V1 scale I’m afraid.
Plus the code is not mine, it was adapted from somewhere (I need to find out where to at least put a thanks in my readme.md when I write it).
But @SimoGh has provided a great link that should allow me to change my script.
I’ve never created a component in HA yet, just created a couple of scripts for components I own that aren’t yet in HA. this could be the opportunity, who knows :wink:

2 Likes

yes that will be great actually. i thought of doing that but my knowledge is too limited for that. i think someone created a fork of your git to create a custom component and asked for contribution to that.

Brian, yes thats what i am doing now. SSHing into a raspberry pi zero w to run the python code. I was trying to run the node somebody referenced at the top of this post, on the nodered addon inside my HASSIO (tinker os). And it was failing.
The separate RasPi Zero W approach has solved it for me for now and additionally it is polling all BLE devices (miflora, mithermometer ) and publishing mqtt on the other side for Hassio to pick from.

short update. I don’t think I can create a “native” component as it requires to run with root privileges, however the link from @SimoGh was very useful and I can recreate the measurements from the official app.
I am working on an updated version of my script that will send via MQTT all the readings as 1 sensor (with lots of attributes)
I’m away tomorrow until the weekend though…

1 Like

I’ve now included the body measurements to be delivered via MQTT, I’ve also added info on setup and usage.

2 Likes

@lolouk44
i successfully edited the variables & execute the script, no error is shown,
i subscribed to lolo/+ and lolo/# but nothing is done.
what can cause this? thanks/

Still no Hass.io Support ?