Compare commits
10 Commits
5b0cceac2d
...
2f286f9c49
Author | SHA1 | Date | |
---|---|---|---|
|
2f286f9c49 | ||
|
1cdc15a37e | ||
|
8c8da92f73 | ||
|
ea9212018f | ||
|
e230de9a41 | ||
|
5e3988699c | ||
|
e3d0b52344 | ||
|
cc807c7a76 | ||
|
3a330324f4 | ||
|
5d44c7f915 |
@ -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
|
||||
|
@ -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/*
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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 + '"'
|
||||
|
Loading…
x
Reference in New Issue
Block a user