-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lolorpi
authored and
lolorpi
committed
Jun 30, 2020
0 parents
commit b700f50
Showing
19 changed files
with
1,076 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behaviour, including error message if any. | ||
|
||
**Expected behaviour** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Scale (please complete the following information):** | ||
- Name | ||
- Model # | ||
|
||
**Device running Home Assistant (please complete the following information):** | ||
- Device used to run the Script/Container [e.g. Raspberry Pi, NUC] | ||
- Bluetooth device used [e.g. Built-in, USB Dongle] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [0.1.4] - 2020-06-29 | ||
### Added | ||
- First release (version in line with non Add-On script for ease of maintenance). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.8-slim | ||
|
||
WORKDIR /opt/miscale | ||
COPY src /opt/miscale | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
bluez \ | ||
python-pip \ | ||
libglib2.0-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
# Copy in docker scripts to root of container... | ||
COPY dockerscripts/ / | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["/cmd.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 lolouk44 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Xiaomi Mi Scale Add On for Home Assistant | ||
|
||
Add-On for [HomeAssistant](https://www.home-assistant.io/) to read weight measurements from Xiaomi Body Scales. | ||
|
||
## Supported Scales: | ||
Name | Model | Picture | ||
--- | --- | :---: | ||
[Mi Smart Scale 2](https://www.mi.com/global/scale) | XMTZC04HM | ![Mi Scale_2](https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Screenshots/Mi_Smart_Scale_2_Thumb.png) | ||
[Mi Body Composition Scale](https://www.mi.com/global/mi-body-composition-scale/) | XMTZC02HM | ![Mi Scale](https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Screenshots/Mi_Body_Composition_Scale_Thumb.png) | ||
[Mi Body Composition Scale 2](https://c.mi.com/thread-2289389-1-0.html) | XMTZC05HM | ![Mi Body Composition Scale 2](https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Screenshots/Mi_Body_Composition_Scale_2_Thumb.png) | ||
|
||
|
||
## Setup | ||
|
||
1. Retrieve the scale's MAC Address based on the Xiaomi Mi Fit app. | ||
|
||
2. Clone this repository | ||
`git clone https://github.com/lolouk44/xiaomi_mi_scale_ha_add_on` | ||
|
||
3. Create a new directory xiaomi_mi_scale in the folder addons in your Home Assistant installation and place all files in it via SSH / Samba | ||
|
||
![Add-On](Screenshots/addon.png) | ||
|
||
4. Open Home Assistant and navigate to add-on store and clock the reload button on the top right corner. Now you should see the Xiaomi Mi Scale as a local add-on | ||
![Add-On Store](Screenshots/addon_store.png) | ||
|
||
5. Install the add-on (takes a while as the container is built locally) | ||
|
||
6. Edit the Configuration | ||
|
||
|
||
Option | Type | Required | Description | ||
--- | --- | --- | --- | ||
HCI_DEV | string | No | Bluetooth hci device to use. Defaults to hci0 | ||
MISCALE_MAC | string | Yes | 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 | ||
|
||
|
||
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! | ||
|
||
Option | Type | Required | Description | ||
--- | --- | --- | --- | ||
USER1_GT | int | Yes | If the weight 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 is less than this number, we'll assume that we're weighing User #2 | ||
USER2_SEX | string | No | male / female | ||
USER2_NAME | string | No | Name of the user | ||
USER2_HEIGHT | int | No |Height (in cm) of the user | ||
USER2_DOB | string | No | DOB (in yyyy-mm-dd format) | ||
USER3_SEX | string | No | male / female | ||
USER3_NAME | string | No | Name of the user | ||
USER3_HEIGHT | int | No |Height (in cm) of the user | ||
USER3_DOB | string | No | DOB (in yyyy-mm-dd format) | ||
|
||
|
||
7. Start the add-on | ||
|
||
|
||
## Home-Assistant Setup: | ||
Under the `sensor` block, enter as many blocks as users configured in your environment variables: | ||
|
||
```yaml | ||
- platform: mqtt | ||
name: "Example Name Weight" | ||
state_topic: "miScale/USER_NAME/weight" | ||
value_template: "{{ value_json['Weight'] }}" | ||
unit_of_measurement: "kg" | ||
json_attributes_topic: "miScale/USER_NAME/weight" | ||
icon: mdi:scale-bathroom | ||
|
||
- platform: mqtt | ||
name: "Example Name BMI" | ||
state_topic: "miScale/USER_NAME/weight" | ||
value_template: "{{ value_json['BMI'] }}" | ||
icon: mdi:human-pregnant | ||
|
||
``` | ||
|
||
![Mi Scale](https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Screenshots/HA_Lovelace_Card.png) | ||
|
||
![Mi Scale](https://github.com/lolouk44/xiaomi_mi_scale/blob/master/Screenshots/HA_Lovelace_Card_Details.png) | ||
|
||
## Acknowledgements: | ||
Thanks to @syssi (https://gist.github.com/syssi/4108a54877406dc231d95514e538bde9) and @prototux (https://github.com/wiecosystem/Bluetooth) for their initial code | ||
|
||
Special thanks to [@ned-kelly](https://github.com/ned-kelly) for his help turning a "simple" python script into a fully fledged docker container | ||
|
||
Thanks to [@bpaulin](https://github.com/bpaulin) for his PRs and collaboration |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "Xiaomi Mi Scale", | ||
"version": "0.1.3", | ||
"slug": "xiaomi_mi_scale", | ||
"description": "Read weight measurements from Xiamomi scale via BLE", | ||
"url": "https://github.com/lolouk44/xiaomi_mi_scale_ha_add_on", | ||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], | ||
"startup": "before", | ||
"boot": "auto", | ||
"panel_admin": false, | ||
"host_network": true, | ||
"privileged": ["NET_ADMIN", "SYS_ADMIN"], | ||
|
||
"options": { | ||
"HCI_DEV": "hci0", | ||
"MISCALE_MAC": "00:00:00:00:00:00", | ||
"MQTT_PREFIX": "miScale", | ||
"MQTT_HOST": "192.168.0.1", | ||
"MQTT_USERNAME": "", | ||
"MQTT_PASSWORD": "", | ||
"MQTT_PORT": 1883, | ||
"TIME_INTERVAL": 30, | ||
|
||
"USER1_GT": 70, | ||
"USER1_SEX": "male", | ||
"USER1_NAME": "Jo", | ||
"USER1_HEIGHT": 175, | ||
"USER1_DOB": "1990-01-01", | ||
|
||
"USER2_LT": 35, | ||
"USER2_SEX": "female", | ||
"USER2_NAME": "Serena", | ||
"USER2_HEIGHT": 95, | ||
"USER2_DOB": "1990-01-01", | ||
|
||
"USER3_SEX": "female", | ||
"USER3_NAME": "Missy", | ||
"USER3_HEIGHT": 150, | ||
"USER3_DOB": "1990-01-01" | ||
|
||
}, | ||
"schema": { | ||
"HCI_DEV": "str", | ||
"MISCALE_MAC": "str", | ||
"MQTT_PREFIX": "str", | ||
"MQTT_HOST": "str", | ||
"MQTT_USERNAME": "str", | ||
"MQTT_PASSWORD": "str", | ||
"MQTT_PORT": "int", | ||
"TIME_INTERVAL": "int", | ||
|
||
"USER1_GT": "int", | ||
"USER1_SEX": "str", | ||
"USER1_NAME": "str", | ||
"USER1_HEIGHT": "int", | ||
"USER1_DOB": "str", | ||
|
||
"USER2_LT": "int", | ||
"USER2_SEX": "str", | ||
"USER2_NAME": "str", | ||
"USER2_HEIGHT": "int", | ||
"USER2_DOB": "str", | ||
|
||
"USER3_SEX": "str", | ||
"USER3_NAME": "str", | ||
"USER3_HEIGHT": "int", | ||
"USER3_DOB": "str" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set -e | ||
python3 -u /opt/miscale/Xiaomi_Scale.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
set -e | ||
exec "$@" |
Oops, something went wrong.