本帖最后由 小铭同学 于 2026-8-16 14:34 编辑
各位大佬好,本人纯小白一枚,最近在 AI 的帮助下,终于搞定了自己那台体脂秤接入 Home Assistant,激动之余分享给大家,也给自己留个记录。 ### 背景 之前看群里消息领了一台沃莱科技(蚂蚁阿福)的体脂秤,型号 AFU-WL-TZ-A1。我手上刚好有一块 ESP32 ,刷了蓝牙代理,最近刚好有时间搞一下 ### 遇到的坑 这个秤比较特殊:站上去测量的时候,它只广播身份信息,不广播测量数据。所以要拿到体重,必须主动连上去走 GATT 读通知。这跟我之前用的另一台乐福秤(纯被动监听广播就行)完全不一样,一开始按旧思路做监听,怎么抓都只有 iBeacon 数据,白折腾了半天。 ### 最终方案 后来查了不少资料,确认走 HA 侧主动连接这条路:利用已有的 ESP32 蓝牙代理,让 HA 自己主动连接体脂秤、订阅 0xFFB2 通知,解析 0xAC 报文。ESP32 固件一个字不用动,完美保住我的蓝牙代理。 ### 集成功能: - 实时体重、阻抗、读数锁定标志
- 本地 BIA 计算:BMI、体脂率、水分率、肌肉量、蛋白质率、骨量
- "测量中"二进制传感器(收到数据即开,15 秒无数据自动关),拿来做仪表盘动画、测量完成通知都很方便
- 自动重连,UI 直接配置 MAC / 身高 / 性别 / 年龄
- 实体带 afu 前缀,家里有多台体脂秤的不会混淆
地址:
安装就是复制 custom_components/afu_scale 到 HA 的 custom_components 下,重启后添加集成即可。README 里写了实体列表、自动化通知示例和 card-mod 动画写法,同款秤的朋友可以直接抄作业。
前端配置代码
<font face="宋体">type: vertical-stack
cards:
- type: custom:mushroom-title-card
title: AFU 体脂秤
subtitle: AFU-WL-TZ-A1 · 沃莱科技
icon: mdi:scale-bathroom
icon_color: blue
- type: horizontal-stack
cards:
- type: custom:mushroom-chips-card
chips:
- type: entity
entity: binary_sensor.afu_ti_zhi_cheng_ce_liang_zhong
name: 测量中
icon: mdi:scale-bathroom
icon_color: blue
state_color: true
- type: entity
entity: sensor.afu_ti_zhi_cheng_zui_jin_ce_liang_shi_jian
name: 最近测量
icon: mdi:clock-outline
- type: grid
columns: 1
square: false
cards:
- type: sensor
entity: sensor.afu_ti_zhi_cheng_ti_zhong
name: 体重
unit_of_measurement: kg
icon: mdi:weight-kilogram
card_mod:
style: >
ha-card {
border-radius: 20px;
background: linear-gradient(135deg, #2a5298, #1e3c72);
color: white;
transition: border 0.3s ease, box-shadow 0.3s ease;
}
.name { font-size: 15px; color: rgba(255,255,255,.8); }
.state { font-size: 44px; font-weight: 700; color: #fff; }
.unit { font-size: 18px; color: rgba(255,255,255,.75); }
{% if is_state('binary_sensor.afu_ti_zhi_cheng_ce_liang_zhong','on')
%}
@keyframes afu-glow {
0% { box-shadow: 0 0 0 0 rgba(255,140,0,.7); border-color: rgba(255,160,0,.9); }
70% { box-shadow: 0 0 0 20px rgba(255,140,0,0); border-color: rgba(255,160,0,.9); }
100% { box-shadow: 0 0 0 0 rgba(255,140,0,0); border-color: rgba(255,160,0,.9); }
}
ha-card {
border: 2px solid rgba(255,160,0,.9);
background: linear-gradient(135deg, #ff7a00, #cc5200);
animation: afu-glow 1.2s ease-out infinite;
}
{% endif %}
- type: grid
columns: 2
square: false
cards:
- type: custom:mushroom-template-card
primary: "{{ states('sensor.afu_ti_zhi_cheng_bmi') | float | round(2) }}"
secondary: BMI
icon: mdi:human-male-height
icon_color: blue
- type: custom:mushroom-template-card
primary: "{{ states('sensor.afu_ti_zhi_cheng_ti_zhi_lu') | float | round(2) }} %"
secondary: 体脂率
icon: mdi:percent
icon_color: red
- type: custom:mushroom-template-card
primary: >-
{{ states('sensor.afu_ti_zhi_cheng_shui_fen_lu') | float | round(2) }}
%
secondary: 水分率
icon: mdi:water-percent
icon_color: cyan
- type: custom:mushroom-template-card
primary: >-
{{ states('sensor.afu_ti_zhi_cheng_ji_rou_liang') | float | round(2)
}} kg
secondary: 肌肉量
icon: mdi:arm-flex-outline
icon_color: green
- type: custom:mushroom-template-card
primary: >-
{{ states('sensor.afu_ti_zhi_cheng_dan_bai_zhi_lu') | float | round(2)
}} %
secondary: 蛋白质率
icon: mdi:egg-outline
icon_color: orange
- type: custom:mushroom-template-card
primary: "{{ states('sensor.afu_ti_zhi_cheng_gu_liang') | float | round(2) }} kg"
secondary: 骨量
icon: mdi:bone
icon_color: brown
- type: custom:mushroom-template-card
primary: "{{ states('sensor.afu_ti_zhi_cheng_dian_zu_kang') }} Ω"
secondary: 电阻抗
icon: mdi:omega
icon_color: purple
- type: custom:mushroom-template-card
primary: "{{ states('sensor.afu_ti_zhi_cheng_ti_zhong') }} kg"
secondary: 实时体重
icon: mdi:scale-bathroom
icon_color: teal
- type: history-graph
title: 体重趋势(7 天)
hours_to_show: 168
entities:
- entity: sensor.afu_ti_zhi_cheng_ti_zhong
name: 体重
</font>
动态展示
如果大家有同型号秤,欢迎测试反馈。代码写得比较简陋,还望大佬们轻喷,多多指教~
|