Integrate the best Xiaomi Mi Scales in Home Assistant
Mi Scales in Home Assistant
We already reviewed the Xiaomi Mi Scale. Xiaomi have beautiful Smart scales for a affordable prices.
The Xiaomi scales are available in de mi-home app, but we want more! A while ago I found a great open source project on github: https://github.com/lolouk44/xiaomi_mi_scale
Due to the work of a fanatic Home assistant user with the nickname Lolouk it’s now possible to integrate several Xiaomi Mi scales in Home Assistant. All credits goes to Lolouk for his work, and help to other users.
Why would you do that? Because it is possible. we want everything in our Home Assistant, everything connected, monitored and controlled, even if we don’t actually use it. Think about things you can do with it: make automations that do something after a weight, or use it so you don’t need the official apps anymore.
- 1 What do you need to Integrate Xiaomi Mi Scales
- 2 Two methods to Integrate Xiaomi Mi Scales in Home Assistant
- 3 1: Xiaomi scale Add-on
- 4 2: Docker
- 5 Integrate in Domoticz or other platforms by MQTT
- 6 Supported Xiaomi Scales
- 7 Related Xiaomi Mi Scale articles on Gadget-freakz
What do you need to Integrate Xiaomi Mi Scales
One of the supported Xiaomi scales (see below), bluetooth (this is a cheap bluetooth dongle for around 4 euro) on your system and time to read this short article 🙂
Two methods to Integrate Xiaomi Mi Scales in Home Assistant
Lolouk made a very nice script. There are two ways to get the scale software up and running. A Home Assistant Add-on which start a docker in the background, and give you the options to configure it in the add-on. Both methods are using the same configuration parameters and send the Weight measuring by MQTT.
If you are not using the add-on store or you have to run the software on another system you can use the manual docker installation. The bluetooth on my Home Assistant machines was not stable enough, so instead of the add-on I switched to the docker setup. I run the docker on a raspberry Pi that I use for octoprint but is perfectly capable of running this docker parallel.
How to configure the Mi Scale script?
Which method you choose is up to you, but configuration is the same for both methods.
1: retrieve the unique bluetooth Mac adress. This can be done by several bleutooth scanner apps but ofcourse also in the Mi Fit App.
Because the software is using MQTT to send the data to your broker, you must enter your own settings.
|HCI_DEV||string||No||Bluetooth hci device to use. Defaults to hci0|
|MISCALE_MAC||string||Yes||Bluetooth Mac address of your scale|
|MQTT_PREFIX||string||No||MQTT Topic Prefix. Defaults to miscale|
|MQTT_HOST||string||Yes||MQTT Server (defaults to 127.0.0.1)|
|MQTT_USERNAME||string||No||Username for MQTT server (comment out if not required)|
|MQTT_PASSWORD||string||No||Password for MQTT (comment out if not required)|
|MQTT_PORT||int||No||Defaults to 1883|
|TIME_INTERVAL||int||No||Time in sec between each query to the scale, to allow other applications to use the Bluetooth module. Defaults to 30|
|MQTT_DISCOVERY||bool||No||MQTT Discovery for Home Assistant Defaults to true|
|MQTT_DISCOVERY_PREFIX||string||No||MQTT Discovery Prefix for Home Assistant. Defaults to homeassistant|
Beside your MQTT settings you need to setup 1 or more users.
|USER1_GT||int||Yes||If the weight (in kg) is greater than this number, we’ll assume that we’re weighing User #1|
|USER1_SEX||string||Yes||male / female|
|USER1_NAME||string||Yes||Name of the user|
|USER1_HEIGHT||int||Yes||Height (in cm) of the user|
|USER1_DOB||string||Yes||DOB (in yyyy-mm-dd format)|
|USER2_LT||int||No||If the weight (in kg) is less than this number, we’ll assume that we’re weighing User #2. Defaults to USER1_GT Value|
|USER2_SEX||string||No||male / female. Defaults to female|
|USER2_NAME||string||No||Name of the user. Defaults to Serena|
|USER2_HEIGHT||int||No||Height (in cm) of the user. Defaults to 95|
|USER2_DOB||string||No||DOB (in yyyy-mm-dd format). Defaults to 1990-01-01|
|USER3_SEX||string||No||male / female. Defaults to female|
|USER3_NAME||string||No||Name of the user. Defaults to Missy|
|USER3_HEIGHT||int||No||Height (in cm) of the user. Defaults to 150|
|USER3_DOB||string||No||DOB (in yyyy-mm-dd format). Defaults to 1990-01-01|
1: Xiaomi scale Add-on
Go to the Home assistant add-on store, add the repository:
The docker methode is a little bit more difficult. In some situations you have no other option.
The easiest way to create the docker, is by using the composer methode.
Please read more about docker, docker-compose and portainer, because it’s fantastic. It’s very simple: create a docker-compose.yaml with your personal settings and save. In the terminal type: nano docker-compose.yaml and paste the (modified) code from below into it and save.
Start up the container with the command
docker-compose up -d
- HCI_DEV=hci0 # Bluetooth hci device to use. Defaults to hci0
- MISCALE_MAC=00:00:00:00:00:00 # Mac address of your scale
- MQTT_HOST=127.0.0.1 # MQTT Server (defaults to 127.0.0.1)
- MQTT_PREFIX=miscale # MQTT Topic Prefix. Defaults to miscale
- MQTT_USERNAME= # Username for MQTT server (comment out if not required)
- MQTT_PASSWORD= # Password for MQTT (comment out if not required)
- MQTT_PORT= # Defaults to 1883
- TIME_INTERVAL=30 # Time in sec between each query to the scale, to allow other applications to use the Bluetooth module. Defaults to 30
- MQTT_DISCOVERY=true # Home Assistant Discovery (true/false), defaults to true
- MQTT_DISCOVERY_PREFIX= # Home Assistant Discovery Prefix, defaults to homeassistant
# Auto-gender selection/config -- This is used to create the calculations such as BMI, Water/Bone Mass etc...
# Up to 3 users possible as long as weights do not overlap!
# Here is the logic used to assign a measured weight to a user:
# if [measured value in kg] is greater than USER1_GT, assign it to USER1
# else if [measured value in kg] is less than USER2_LT, assign it to USER2
# else assign it to USER3 (e.g. USER2_LT < [measured value in kg] < USER1_GT)
- USER1_GT=70 # If the weight (in kg) is greater than this number, we'll assume that we're weighing User #1
- USER1_SEX=male # male / female
- USER1_NAME=Jo # Name of the user
- USER1_HEIGHT=175 # Height (in cm) of the user
- USER1_DOB=1990-01-01 # DOB (in yyyy-mm-dd format)
- USER2_LT=35 # If the weight (in kg) is less than this number, we'll assume that we're weighing User #2
- USER2_SEX=female # male / female
- USER2_NAME=Serena # Name of the user
- USER2_HEIGHT=95 # Height (in cm) of the user
- USER2_DOB=1990-01-01 # DOB (in yyyy-mm-dd format)
- USER3_SEX=female # male / female
- USER3_NAME=Missy # Name of the user
- USER3_HEIGHT=150 # Height (in cm) of the user
- USER3_DOB=1990-01-01 # DOB (in yyyy-mm-dd format)
Integrate in Domoticz or other platforms by MQTT
The software is using MQTT to transfer data to the broker you are using. The only thing you need to have is a MQTT broker. This means that you can pick up the data from your broker also by Domoticz, Node-red or other programs that support MQTT. This way you can integrate Xiaomi Mi Scales in almost everything 🙂
Supported Xiaomi Scales
|Mi Smart Scale 2||XMTZCO1HM, XMTZC04HM|
|Mi Body Composition Scale||XMTZC02HM|
|Mi Body Composition Scale 2||XMTZC05HM|