Integrating Xiaomi Mi Scale

Hey i works! :slight_smile:
I can record my Corona kilos :smiley:
I got everything, all the data and the config setup work fine!
Thanks a bunch!

1 Like

Great stuff. I’ll try and incorporate the code changes in the main docker image so it’s quicker to install. Then I’ll see how feasible it would be for it to be an official add-on. Out of interest what pi do you use and what Bluetooth radio

For those still interested, 0.1.6 released:

  • Add-On support including use of docker image (so no local build required)
  • MQTT Discovery is now supported by both add-on and “normal” docker container.

Good job! :slight_smile:

1 Like

first off all great job! It works!
I’m running esxi 7 on my intel nuc en installed ubuntu with hassio.
I got a lot off errors but it looks like the data came trough:

2020-07-03 19:29:21 - Starting Xiaomi mi Scale...
2020-07-03 19:29:21 - Loading Config From Add-On Options...
2020-07-03 19:29:21 - Config Loaded...
2020-07-03 19:29:21 - Discovery Completed...
2020-07-03 19:29:26 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:30:02 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:30:37 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 13, error: Invalid Parameters)
2020-07-03 19:31:43 - Publishing data to topic miScale/Remco/weight: {"Weight":"77.40","BMI":"21.44","Basal Metabolism":"1571.47","Visceral Fat":"10.38","TimeStamp":"2020-07-03-19:31:43"}
2020-07-03 19:31:43 - Data Published ...
2020-07-03 19:32:25 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:33:02 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:33:37 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:34:08 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:35:51 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:36:26 - Bluetooth connection error: Failed to execute management command 'scanend'
2020-07-03 19:36:58 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:37:29 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:38:00 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:38:00 - 5+ Bluetooth connection errors. Resetting Bluetooth...
2020-07-03 19:39:35 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:40:13 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 3, error: Failed)
2020-07-03 19:40:44 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:41:14 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:41:44 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:41:44 - 5+ Bluetooth connection errors. Resetting Bluetooth...
2020-07-03 19:42:54 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:43:31 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:44:01 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)
2020-07-03 19:44:35 - Publishing data to topic miScale/Remco/weight: {"Weight":"77.95","BMI":"21.59","Basal Metabolism":"1579.67","Visceral Fat":"10.64","TimeStamp":"2020-07-03-19:44:35"}
2020-07-03 19:44:35 - Data Published ...
2020-07-03 19:45:14 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 13, error: Invalid Parameters)
2020-07-03 19:46:20 - Publishing data to topic miScale/Annika/weight: {"Weight":"67.45","BMI":"21.53","Basal Metabolism":"1267.61","Visceral Fat":"1.00","TimeStamp":"2020-07-03-19:46:20"}
2020-07-03 19:46:20 - Data Published ...

Thanks. Can you raise an issue on the repo please?

0.1.7 released…

  • MQTT Discovery set with retain flag
  • Repository set up so cloning is no longer required
  • Add-On optional config is now truly optional
1 Like

I got it working on a raspberry pi. So I asume that it has something to do with bluetooth from NUC > esxi > ubuntu. I don’t give it up now. but in the time beeing the raspberry pi does the work for now :slight_smile:

Thanks. Have you tried with a bt usb stick?

I’m willing to test but i’m getting the following error:

image

running 0.112.4 on a pi4.

Are you sure you’re adding a custom repo under Add-Ons?
Sounds like you’re trying to add an HACS Repo…

Yes correct sorry. Managed to get it installed correctly.
However i’m unable to find the MAC Address, how do i find that?

use the Xiaomi Mi Fit App, check the repo for more assistance / screenshots

That’s what i went through before commenting here.
Your instructions only explain where to get the Bluetooth address which is optional… According to your instructions the mac address is needed.

I’m confused…
the mac address that you need is the bluetooth mac address of the scale, as shown in the app. It’s not optional, if you don’t provide it, the app doesn’t know which device to connect to…

Installation was OK now.

The weight gets saved in the Mi Fit app and i’m able to use the sensor.weight however it’s status unknown.

I’m using the Mi scale composition 2 with the compatible model number.

Addon config:

HCI_DEV: hci0
MISCALE_MAC: ‘5C:CA:D3:3E:C2:28’
MQTT_PREFIX: miscale
MQTT_HOST: 192.168.2.24
MQTT_USERNAME: mqtt
MQTT_PASSWORD: removed
MQTT_PORT: 1883
TIME_INTERVAL: 30
MQTT_DISCOVERY: true
MQTT_DISCOVERY_PREFIX: homeassistant
USER1_GT: 80
USER1_SEX: male
USER1_NAME: Melvin
USER1_HEIGHT: 184
USER1_DOB: ‘1994-13-06’
USER2_LT: 79
USER2_SEX: female
USER2_NAME: Lisa
USER2_HEIGHT: 168
USER2_DOB: ‘1997-15-01’
USER3_SEX: female
USER3_NAME: Missy
USER3_HEIGHT: 150
USER3_DOB: ‘1990-01-01’

Addon logs:


2020-07-15 18:53:48 - Starting Xiaomi mi Scale…
2020-07-15 18:53:48 - Loading Config From Add-On Options…
2020-07-15 18:53:48 - Config Loaded…
2020-07-15 18:53:49 - Discovery Completed…
2020-07-15 19:05:35 - Publishing data to topic miscale/Missy/weight: {“Weight”:“80.00”,“BMI”:“35.56”,“Basal Metabolism”:“1432.31”,“Visceral Fat”:“10.94”,“Lean Body Mass”:“52.58”,“Body Fat”:“48.01”,“Water”:“37.12”,“Bone Mass”:“2.57”,“Muscle Mass”:“39.03”,“Protein”:“11.66”,“Body Type”:“Thick-set”,“Metabolic Age”:“80”,“TimeStamp”:“2020-07-15-19:05:35”}
2020-07-15 19:05:36 - Data Published …

Lovelace card:

I’m able to connect via MQTT explorer and this gets accepted in the log files so MQTT is setup succesfully.

LOG:
594835005: New connection from 192.168.2.29 on port 1883.
[INFO] found mqtt on Home Assistant
1594835006: New client connected from 192.168.2.29 as mqtt-explorer-b2171cec (p2, c1, k60, u’mqtt’).

However the MiFit app data weight sensor is not updated in home assistant.

Hi, sure! Since I only have 24hs of HASS… i must ask how to do it. Asides from that, i-ve been working withs osftware for the last 20 years :slight_smile:

Thanks. Just follow the instructions on the add-on page:

You need to adjust your USER1_GT config
For the weigh to be assigned to user1, the weight needs to be more than 80Kg. Turns out it was exactly 80Kg.
80Kg is not greater than 80Kg, and it’s not less than 79Kg so the weight got assigned to the 3rd user, “Missy” as per the log entry:
2020-07-15 19:05:35 - Publishing data to topic miscale/Missy/weight:

In addition, your dates or birth are in the wrong format.
They should be in YYYY-MM-DD. Sounds like you added them in YYYY-DD-MM so the calculations will be wrong…

Trying to get this working running Hass Supervised in docker on linux server. I am using the add on through HA.
I have plugged at USB BT device into the machine, when running hcitool dev it shows no devices listed

tom@ubuntu_server:~$ hcitool dev
Devices:

Im still learning the ropes on Ubuntu, but I assume I need to mount this device in Linux then expose to docker?

Any tips?

Thanks!