我自己用的:
我对Hass还不太熟悉,希望有大佬优化这个配置
这个配置可能和我GitHub上有点区别,我自己使用过程可能会为了测试修改一点点
把里面的b0f8932234f4 替换成你自己的mac试试
sensor:
- platform: mqtt
name: 'zm1_b0f8932234f4_temperature'
# friendly_name: 温度
state_topic: 'device/zm1/b0f8932234f4/sensor'
unit_of_measurement: '°C'
icon: 'mdi:thermometer'
value_template: '{{ value_json.temperature }}'
#availability_topic: "device/zm1/b0f8932234f4/availability"
#payload_available: 1
#payload_not_available: 0
- platform: mqtt
name: 'zm1_b0f8932234f4_humidity'
# friendly_name: 湿度
state_topic: 'device/zm1/b0f8932234f4/sensor'
unit_of_measurement: '%'
icon: mdi:water-percent
value_template: '{{ value_json.humidity }}'
#availability_topic: "device/zm1/b0f8932234f4/availability"
#payload_available: 1
#payload_not_available: 0
- platform: mqtt
name: 'zm1_b0f8932234f4_pm25'
#availability_topic: "device/zm1/b0f8932234f4/availability"
#payload_available: 1
#payload_not_available: 0
# friendly_name: PM25
state_topic: 'device/zm1/b0f8932234f4/sensor'
unit_of_measurement: 'μg/m³'
icon: mdi:blur
value_template: '{{ value_json.PM25 }}'
- platform: mqtt
name: 'zm1_b0f8932234f4_hcho'
# friendly_name: 甲醛
state_topic: 'device/zm1/b0f8932234f4/sensor'
unit_of_measurement: 'mg/m³'
icon: mdi:chemical-weapon
value_template: '{{ value_json.formaldehyde }}'
# availability_topic: "device/zm1/b0f8932234f4/availability"
# payload_available: 1
# payload_not_available: 0
input_number:
zm1_brightness_b0f8932234f4:
name: zm1亮度_b0f8932234f4
initial: 4
min: 0
max: 4
step: 1
icon: mdi:weather-windy
# availability_topic: "device/zm1/b0f8932234f4/availability"
# payload_available: 1
# payload_not_available: 0
automation:
#获取zM1亮度
- alias: get_zm1_brightness_b0f8932234f4
trigger:
platform: mqtt
topic: 'device/zm1/b0f8932234f4/state'
action:
- service: homeassistant.turn_off
data:
entity_id: automation.set_zm1_brightness_b0f8932234f4
- service: input_number.set_value
data_template:
entity_id: input_number.zm1_brightness_b0f8932234f4
value: "{{ trigger.payload_json.brightness }}"
#设置zM1亮度
- alias: set_zm1_brightness_b0f8932234f4
trigger:
platform: state
entity_id: input_number.zm1_brightness_b0f8932234f4
action:
- service: homeassistant.turn_on
data:
entity_id: automation.set_zm1_brightness_b0f8932234f4
- service: mqtt.publish
data_template:
topic: 'device/zm1/b0f8932234f4/set'
retain: false
payload: "{"mac":"b0f8932234f4","brightness":{{ states('input_number.zm1_brightness_b0f8932234f4') | int }}}"
#设置zM1发送亮度自动化延时打开
- alias: open_set_zm1_brightness_b0f8932234f4_delay
trigger:
platform: mqtt
topic: 'device/zm1/b0f8932234f4/state'
action:
- delay: 00:00:00.20
- service: homeassistant.turn_on
data:
entity_id: automation.set_zm1_brightness_b0f8932234f4
homeassistant:
customize:
sensor.zm1_b0f8932234f4_temperature:
friendly_name: zM1温度
sensor.zm1_b0f8932234f4_humidity:
friendly_name: zM1湿度
sensor.zm1_b0f8932234f4_pm25:
friendly_name: zM1 PM2.5
sensor.zm1_b0f8932234f4_hcho:
friendly_name: zM1甲醛
复制代码