Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qbbr/mi-scale-2
Get Xiaomi Mi Smart Scale 2 weight and publishing to mqtt
https://github.com/qbbr/mi-scale-2
bluetooth-low-energy mqtt python3 raspberry-pi reverse-engineering xiaomi xiaomi-miscale
Last synced: about 1 month ago
JSON representation
Get Xiaomi Mi Smart Scale 2 weight and publishing to mqtt
- Host: GitHub
- URL: https://github.com/qbbr/mi-scale-2
- Owner: qbbr
- License: mit
- Created: 2020-03-16T10:48:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T15:22:45.000Z (about 1 year ago)
- Last Synced: 2023-12-14T16:36:03.248Z (about 1 year ago)
- Topics: bluetooth-low-energy, mqtt, python3, raspberry-pi, reverse-engineering, xiaomi, xiaomi-miscale
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mi-scale-2
Get Xiaomi Mi Smart Scale 2 weight and publishing to mqtt
*Tested only on Raspberry Pi 3b + Mi Scale 2*
## Requirements
* python3
* python-dotenv
* bluepy
* paho-mqtt
* root permission for `bluepy.btle````bash
sudo pip install -r requirements.txt
```## Usage
always run with `sudo` or from `root`:
```bash
cp .env.dist .env
vim .env
sudo ./main.py
# sudo ./main.py --help
# sudo ./main.py --loglevel=DEBUG
```## Autostart
```bash
sudo cp mi-scale-2.service /etc/systemd/system/
sudo systemctl enable mi-scale-2
sudo systemctl start mi-scale-2
```## Integrate with Home Assistant
[![qbbr-mi-scale-2-home-assistant-integration](https://i.imgur.com/rRetkYZ.png)](https://i.imgur.com/rRetkYZ.png)
```yaml
# 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: Мой вес
```## Help
get dev mac address:
```bash
sudo hcitool lescan
```if u have troubleshoots, try restart u bluetooth/adapter
```bash
sudo hciconfig hci0 reset
sudo invoke-rc.d bluetooth restart
```### Reverse Engineering RAW Schema for Mi Scale 2
!!! *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)## Links
* https://github.com/oliexdev/openScale/wiki/Xiaomi-Bluetooth-Mi-Scale