悟空M1接入HA最新教程
先来看HA的版本

接入效果

具体方法如下:
打开home assistant 在左边栏找到文件管理点开他,看到文件夹点开找到里面的配置文件



点开配置文件进行编辑 移到最后一行添加如下配置:
mqtt:
# 传感器部分
sensor:
- name: "zm1_你的M1 mac地址_temperature"
state_topic: "device/zm1/你的M1 mac地址/sensor"
unit_of_measurement: "°C"
icon: "mdi:thermometer"
value_template: "{{ value_json.temperature }}"
unique_id: "zm1_你的M1 mac地址_temp" # 推荐添加,确保唯一性
- name: "zm1_你的M1 mac地址_humidity"
state_topic: "device/zm1/你的M1 mac地址/sensor"
unit_of_measurement: "%"
icon: "mdi:water-percent"
value_template: "{{ value_json.humidity }}"
unique_id: "zm1_你的M1 mac地址_hum"
- name: "zm1_你的M1 mac地址_pm25"
state_topic: "device/zm1/你的M1 mac地址/sensor"
unit_of_measurement: "μg/m³"
icon: "mdi:blur"
value_template: "{{ value_json.PM25 }}"
unique_id: "zm1_你的M1 mac地址_pm25"
- name: "zm1_你的M1 mac地址_hcho"
state_topic: "device/zm1/你的M1 mac地址/sensor"
unit_of_measurement: "mg/m³"
icon: "mdi:chemical-weapon"
value_template: "{{ value_json.formaldehyde }}"
unique_id: "zm1_你的M1 mac地址_hcho"
# 灯光(亮度控制)部分
light:
- name: "zm1_你的M1 mac地址_brightness"
schema: template
command_topic: "device/zm1/你的M1 mac地址/set"
state_topic: "device/zm1/你的M1 mac地址/state"
command_on_template: >
{"mac": "你的M1 mac地址"
{%- if brightness is defined -%}
, "brightness": {{ ((brightness-1) / 64 )|int +1 }}
{%- else -%}
, "brightness": 4
{%- endif -%}
}
command_off_template: '{"mac": "你的M1 mac地址", "brightness": 0}'
state_template: >
{%- if value_json.brightness == 0 -%}
off
{%- else -%}
on
{%- endif -%}
brightness_template: >
{%- if value_json.brightness is defined -%}
{{ ( value_json.brightness * 64 )|int }}
{%- endif -%}
unique_id: "zm1_你的M1 mac地址_light"
# 自定义实体名称 (保持不变)
homeassistant:
customize:
light.zm1_你的M1 mac地址_brightness:
friendly_name: "悟空M1 亮度"
sensor.zm1_你的M1 mac地址_temperature:
friendly_name: "悟空M1 温度"
sensor.zm1_你的M1 mac地址_humidity:
friendly_name: "悟空M1 湿度"
sensor.zm1_你的M1 mac地址_pm25:
friendly_name: "悟空M1 PM2.5"
sensor.zm1_你的M1 mac地址_hcho:
friendly_name: "悟空M1 甲醛"
此时你的HA里面的MQTT就会发现M1


最后就是添加前端卡片:
回到HA主页面在你的仪表盘里面点编辑选择添加新部件:


滑倒最下面选择手动

在卡片配置页面输入以下代码:
type: custom:swipe-card
parmameters:
loop: true
effect: coverflow
cards:
- type: custom:stack-in-card
title: M1空气检测仪
mode: vertical
cards:
- type: horizontal-stack
cards:
- type: custom:mod-card
card:
type: picture
image: /local/UI/m1.jpg
card_mod: null
style: |
ha-card {
/* Set padding of card */
padding: 0px 0px 0px 0px;
/* Move card up to match header card */
--ha-card-border-radius: 0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
- type: custom:mushroom-entity-card
entity: sensor.zm1_b0f893286af7_temperature
name: 温度
layout: vertical
icon: mdi:thermometer
icon_color: green
- type: custom:mushroom-entity-card
entity: sensor.zm1_b0f893286af7_humidity
name: 湿度
layout: vertical
icon: mdi:water-percent
icon_color: blue
- type: horizontal-stack
cards:
- type: custom:mushroom-entity-card
entity: sensor.zm1_b0f893286af7_pm25
name: PM2.5
layout: vertical
icon: mdi:blur
icon_color: yellow
- type: custom:mushroom-entity-card
entity: sensor.zm1_b0f893286af7_hcho
name: 甲醛
layout: vertical
icon: mdi:chemical-weapon
icon_color: purple
- type: custom:stack-in-card
title: M1亮度
mode: vertical
cards:
- type: custom:mushroom-light-card
entity: light.zm1_b0f893286af7_brightness
use_light_color: false
show_brightness_control: true
show_color_control: false
show_color_temp_control: false
icon_color: light-green
icon: mdi:lightbulb-night-outline
layout: vertical
记得点保存然后点击完成

swipe-card这个卡片需在HACS里面提前下载
m1.jpg图片需放到HA的配置文件夹里面www文件夹下UI文件夹里面

ScotGu
校验提示文案
Candyank
校验提示文案
没有蟹黄堡
校验提示文案
华中张大侠
校验提示文案
winflowers
在 21:46 收到“device/zm1/mac隐藏了/sensor”的消息 3:
{
"mac": "mac隐藏了",
"temperature": "24.4",
"humidity": "79.7",
"formaldehyde": "0.01",
"PM25": "22"
}
校验提示文案
小绵羊dad
校验提示文案
小小小tiny
校验提示文案
无字添书
校验提示文案
因吹斯汀_
校验提示文案
benjaminty
校验提示文案
vikien
校验提示文案
值友4192379302
校验提示文案
李员外爱吃肉
校验提示文案
vikien
校验提示文案
benjaminty
校验提示文案
因吹斯汀_
校验提示文案
无字添书
校验提示文案
小绵羊dad
校验提示文案
winflowers
在 21:46 收到“device/zm1/mac隐藏了/sensor”的消息 3:
{
"mac": "mac隐藏了",
"temperature": "24.4",
"humidity": "79.7",
"formaldehyde": "0.01",
"PM25": "22"
}
校验提示文案
华中张大侠
校验提示文案
没有蟹黄堡
校验提示文案
Candyank
校验提示文案
小小小tiny
校验提示文案
ScotGu
校验提示文案
李员外爱吃肉
校验提示文案
值友4192379302
校验提示文案