Integrating Xiaomi Mi Scale

Yes it works.
I’ve not had time to try and make it cleaner and when the scale is sleeping you tend to get an error message thrown out (see above message from @Stooovie), but that doesn’t not impact it.

I’ve not worked on the MiFlora integration so no ideas how I would go about adding the scale in the same way. If / when I get some time I might look into it. I already need to review the body measurement formulas as they have been updated…

@lolouk44 Is a hass.io support via addon planned? I will receive my scale in a week and am running hass.io, I would be happy to help you with testing. Alternatively I am thinking about using an esp32 as a gateway

I’m sorry I don’t use hass.io so have no idea on how to build an add on for it.

you great job !

I wish this component can be used in Home Assistant next version.

1 Like

Hi guys,
Is there still someone who can help with simple understanding code of @lolouk44 and how to do this project with hass.io? :slight_smile:

2 Likes

Hi folks,

I wrote this night an hassio addon leveraging @lolouk44’s scripts. There were a few modifications in the python classes and Dockerfile necessary. But the tricky thing was to access the Raspberry Pi 4’s bluetooth device inside the docker container on HassOS.

image

image

Unfortunately, the scale measurements aside of weight are ridiculous - I already expected inaccuracy as I usualy use a caliper but this is just “useless”. Thus, I will also adjust the code to support stepping of the scale immediately after weight measurement to skip the second impedance measurement.

After a code cleanup I will upload the addon to GitHub in the next days.

Merry Christmas!! :tada:

5 Likes

Super awesome! Can’t wait until it is on GitHub! :grinning:

Thanks @lolouk44 @Tobi0892 and everyone else ! :heart:

I waiting for that very clever solution :smiley:

Attached the initial beta version of the addon tested on a raspberry pi 4 @Patrick97 @abaksa1 @krovachek @N-l1

Good afternoon, maybe you can guide me how I could integrate a scale “my scale 2” for a system that I am doing in javaFX.

I want to capture the weight of the scale

I would really appreciate it thanks

Could you setup this add-on to use a configuration with the hardware address of the bluetooth adapter, please?

Would be awesome for other hardware than rpi 4, like VM running on proxmox with a bluetooth usb dongle.

Thanks.

@ReDaLeRt in the config.json you can adjust the device string according to your needs. That should work also for an usb dongle. Alternatively you can tinker with the privileges or full_access if needed:
https://developers.home-assistant.io/docs/en/0.78.0/hassio_addon_config.html

@Carlos_Sanchez you can leverage the xiaomi_scale.py and xiaomi_scale_body_metrics.py. The former does the ble scanning and the latter calculates the body metrics based on the weight and impedation

1 Like

Hello Tobi0892 good job!
I have such a problem

’ 19-12-29 17:57:16 INFO (SyncWorker_10) [hassio.docker.addon] Start build local/armv7-addon-xiaomi_mi_scale:0.7
19-12-29 17:57:17 ERROR (SyncWorker_10) [hassio.docker.addon] Can’t build local/armv7-addon-xiaomi_mi_scale:0.7: 500 Server Error: Internal Server Error (“Cannot locate specified Dockerfile: Dockerfile”)’

Host system

Hostname hassio

System HassOS 3.7
arch armv7
dev false
docker true
hassio true
os_name Linux
python_version 3.7.5
version 0.103.5
virtualenv false

Lovelace

mode storage
resources 3
views 8

In the root directory of the repository is the Dockerfile, have you copied that one to the addon folder, too?

addons\xiaomi_mi_scale
\dockerscripts
\src
-config
-Dockerfile
I added files via ftp, does it matter?

I assume the config file is still of type json and you already tried to reboot the entire system? What hardware do you run?

Somehow the supervisor complains that the Dockerfile can’t be opened. Was there maybe an issue during FTP transfer?

yes im reboot system, i have raspberry pi3 b+,I have it as .txt, maybe another extension?

serial:
    /dev/ttyAMA0
input:
disk:
    /dev/mmcblk0
    /dev/mmcblk0p7
    /dev/mmcblk0p1
    /dev/mmcblk0p3
    /dev/mmcblk0p5
    /dev/mmcblk0p8
    /dev/mmcblk0p2
    /dev/mmcblk0p6
    /dev/mmcblk0p4
gpio:
    gpiochip504
    gpiochip0
audio:
    0:
        name: bcm2835_alsa - bcm2835 ALSA
        type: ALSA
        devices:
            [object Object]
            [object Object]
            [object Object]

@Tobi0892 Do you have hassio.io installed on yours RP? Because I already installed raspbian and after seraching internet I found only haspbian. I tried to install HA manually, but there is no hassio.io. Maybe you know how to do that, because I need RB as a single device. :frowning:

@Patrick97 I used HassOS underneath Hass.io: https://www.home-assistant.io/hassio/installation/

Do you still get the Dockerfiile error or a new one? In case it stops with the Dockerfile error you do not need to worry about the Bluetooth interface, yet