Get Xiaomi Mi Smart Scale 2 weight and publishing to mqtt
Tested only on Raspberry Pi 3b + Mi Scale 2
- python3
- python-dotenv
- bluepy
- paho-mqtt
- root permission for
bluepy.btle
sudo pip install -r requirements.txt
always run with sudo
or from root
:
cp .env.dist .env
vim .env
sudo ./main.py
# sudo ./main.py --help
# sudo ./main.py --loglevel=DEBUG
sudo cp mi-scale-2.service /etc/systemd/system/
sudo systemctl enable mi-scale-2
sudo systemctl start mi-scale-2
# configuration.yaml:
mqtt:
sensor:
- name: "my_weight"
state_topic: "miscale/qbbr/weight"
force_update: true
unit_of_measurement: "kg"
state_class: "measurement"
icon: mdi:scale
# customize.yaml:
sensor.my_weight:
friendly_name: Мой вес
get dev mac address:
sudo hcitool lescan
if u have troubleshoots, try restart u bluetooth/adapter
sudo hciconfig hci0 reset
sudo invoke-rc.d bluetooth restart
!!! slightly different than from openScale wiki !!!
byte 0:
- 0 bit - unknown
- 1 bit - unit kg
- 2 bit - unit lbs
- 3 bit - unknown
- 4 bit - jin (chinese catty) unit
- 5 bit - stabilized
- 6 bit - unknown
- 7 bit - weight removed
byte 1-2:
- weight (little endian)