Compare commits

...

10 Commits

Author SHA1 Message Date
evlic
2f286f9c49 fix: docker ci 2023-09-15 00:30:23 +08:00
5high
1cdc15a37e
Update README.md 2021-06-28 15:55:29 +08:00
5high
8c8da92f73
Update README.md 2021-06-28 15:55:10 +08:00
5high
ea9212018f
Update README.md 2021-01-11 17:50:18 +08:00
5high
e230de9a41
Update Xiaomi_Scale.py 2021-01-11 10:52:43 +08:00
5high
5e3988699c
Update Xiaomi_Scale.py 2021-01-11 09:17:52 +08:00
5high
e3d0b52344
Update Xiaomi_Scale.py 2021-01-10 19:19:29 +08:00
5high
cc807c7a76
Update Xiaomi_Scale.py 2021-01-10 19:09:58 +08:00
5high
3a330324f4
Update Xiaomi_Scale.py 2021-01-10 17:34:29 +08:00
5high
5d44c7f915
Update Xiaomi_Scale.py 2021-01-10 17:26:02 +08:00
4 changed files with 39 additions and 7 deletions

View File

@ -4,6 +4,10 @@ Xiaomi Mi Scale Add On for Home Assistant
Fork 了大神的小米体脂秤addons汉化一下。
作者主页https://github.com/lolouk44/hassio-addons
我的主页https://sumju.net
YouTube: https://www.youtube.com/channel/UCf8MbF6J9xWf1m9guutozlw/
Bilibili: https://space.bilibili.com/441936678
Docker Push命令
docker buildx build --platform linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6 -t 5high/xiaomi-mi-scale-ha-add-on:0.1.16 . --push

View File

@ -3,9 +3,10 @@ LABEL io.hass.version="0.1.16" io.hass.type="addon" io.hass.arch="armhf|aarch64|
WORKDIR /opt/miscale
COPY src /opt/miscale
RUN apt-get update && apt-get install -y \
RUN sed -i 's/http:\/\/deb.debian.org/https:\/\/mirrors.cloud.tencent.com/g' /etc/apt/sources.list.d/debian.sources \
&& apt-get update && apt-get install -y \
bluez \
python-pip \
python3-pip \
libglib2.0-dev && \
rm -rf /var/lib/apt/lists/*

View File

@ -1,3 +1,12 @@
# Fork 了大神的小米体脂秤addons汉化一下。
作者主页https://github.com/lolouk44/hassio-addons
更多教程 https://sumju.net
电报 群 https://t.me/joinchat/J26zVFGMhWWB1sBTFvcjaA
电报频道 https://t.me/itcommander
Twitter : https://twitter.com/itcommander2
Facebook: https://www.facebook.com/itcommander.itcommander.1
# 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.

View File

@ -192,9 +192,9 @@ OLD_MEASURE = ''
def discovery():
for MQTTUser in (USER1_NAME,USER2_NAME,USER3_NAME):
message = '{"name": "' + MQTTUser + ' ",'
message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/重量","value_template": "{{ value_json.weight }}",'
message+= '"json_attributes_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/重量","icon": "mdi:scale-bathroom"}'
message = '{"name": "' + MQTTUser + ' ",'
message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json.重量 }}",'
message+= '"json_attributes_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","icon": "mdi:scale-bathroom"}'
publish.single(
MQTT_DISCOVERY_PREFIX + '/sensor/' + MQTT_PREFIX + '/' + MQTTUser + '/config',
message,
@ -282,14 +282,32 @@ class ScanProcessor():
if hasImpedance:
lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(calcweight, height, age, sex, int(miimpedance))
bodyscale = ['肥胖型', '超重型', '壮实型', '缺乏锻炼型', '平衡型', '平衡肌肉型', '偏瘦型', '平衡瘦型', '瘦肌肉型']
bodyscale = ['Obese', 'Overweight', 'Thick-set', 'Lack-exerscise', 'Balanced', 'Balanced-muscular', 'Skinny', 'Balanced-skinny', 'Skinny-muscular']
message += ',"去脂体重":' + "{:.2f}".format(lib.getLBMCoefficient())
message += ',"体脂":' + "{:.2f}".format(lib.getFatPercentage())
message += ',"水分":' + "{:.2f}".format(lib.getWaterPercentage())
message += ',"骨量":' + "{:.2f}".format(lib.getBoneMass())
message += ',"肌肉量":' + "{:.2f}".format(lib.getMuscleMass())
message += ',"蛋白质":' + "{:.2f}".format(lib.getProteinPercentage())
message += ',"身体类型":"' + str(bodyscale[lib.getBodyType()]) + '"'
if str(bodyscale[lib.getBodyType()]) == "Overweight":
bodytype = "超重型"
elif str(bodyscale[lib.getBodyType()]) == "Obese":
bodytype = "肥胖型"
elif str(bodyscale[lib.getBodyType()]) == "Thick-set":
bodytype = "壮实型"
elif str(bodyscale[lib.getBodyType()]) == "Lack-exerscise":
bodytype = "缺乏运动型"
elif str(bodyscale[lib.getBodyType()]) == "Balanced":
bodytype = "平衡型"
elif str(bodyscale[lib.getBodyType()]) == "Balanced-muscular":
bodytype = "平衡肌肉型"
elif str(bodyscale[lib.getBodyType()]) == "Skinny":
bodytype = "偏瘦型"
elif str(bodyscale[lib.getBodyType()]) == "Balanced-skinny":
bodytype = "平衡瘦型"
elif str(bodyscale[lib.getBodyType()]) == "Skinny-muscular":
bodytype = "瘦肌肉型"
message += ',"身体类型":"' + bodytype + '"'
message += ',"代谢年龄":' + "{:.0f}".format(lib.getMetabolicAge())
message += ',"测量时间":"' + mitdatetime + '"'