mqtt:
sensor:
- name: 'zm1_b0f89324b2ac_temperature'
unique_id: zm1_b0f89324b2ac_temperature
state_topic: 'device/zm1/b0f89324b2ac/sensor'
unit_of_measurement: '°C'
device_class: temperature
value_template: '{{ value_json.temperature }}'
expire_after: "180"
state_class: "measurement"
- name: 'zm1_b0f89324b2ac_humidity'
unique_id: zm1_b0f89324b2ac_humidity
state_topic: 'device/zm1/b0f89324b2ac/sensor'
unit_of_measurement: '%'
device_class: humidity
value_template: '{{ value_json.humidity }}'
expire_after: "180"
state_class: "measurement"
- name: 'zm1_b0f89324b2ac_pm25'
unique_id: zm1_b0f89324b2ac_pm25
state_topic: 'device/zm1/b0f89324b2ac/sensor'
unit_of_measurement: 'μg/m³'
icon: mdi:blur
value_template: '{{ value_json.PM25 }}'
expire_after: "180"
state_class: "measurement"
- name: 'zm1_b0f89324b2ac_hcho'
unique_id: zm1_b0f89324b2ac_hcho
state_topic: 'device/zm1/b0f89324b2ac/sensor'
unit_of_measurement: 'mg/m³'
icon: mdi:chemical-weapon
value_template: '{{ value_json.formaldehyde }}'
expire_after: "180"
state_class: "measurement"
light:
- name: zm1_b0f89324b2ac_brightness
unique_id: zm1_b0f89324b2ac_brightness
schema: template
command_topic: "device/zm1/b0f89324b2ac/set"
state_topic: "device/zm1/b0f89324b2ac/state"
command_on_template: >
{"mac": "b0f89324b2ac"
{%- if brightness is defined -%}
, "brightness": {{ ((brightness-1) / 64 )|int +1 }}
{%- else -%}
, "brightness": 4
{%- endif -%}
}
command_off_template: '{"mac": "b0f89324b2ac", "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 -%}
用我的给你参考一下吧
|