ZM1代码怎么加到Hass?
sensor:
- platform: mqtt
name: 'zm1_MACMAC_temperature'
# friendly_name: 温度
state_topic: 'device/zm1/MACMAC/sensor'
unit_of_measurement: '°C'
icon: 'mdi:thermometer'
value_template: '{{ value_json.temperature }}'
- platform: mqtt
name: 'zm1_MACMAC_humidity'
# friendly_name: 湿度
state_topic: 'device/zm1/MACMAC/sensor'
unit_of_measurement: '%'
icon: mdi:water-percent
value_template: '{{ value_json.humidity }}'
- platform: mqtt
name: 'zm1_MACMAC_pm25'
# friendly_name: PM25
state_topic: 'device/zm1/MACMAC/sensor'
unit_of_measurement: 'μg/m³'
icon: mdi:blur
value_template: '{{ value_json.PM25 }}'
- platform: mqtt
name: 'zm1_MACMAC_hcho'
# friendly_name: 甲醛
state_topic: 'device/zm1/MACMAC/sensor'
unit_of_measurement: 'mg/m³'
icon: mdi:chemical-weapon
value_template: '{{ value_json.formaldehyde }}'
light:
- platform: mqtt
name: zm1_MACMAC_brightness
schema: template
command_topic: "device/zm1/MACMAC/set"
state_topic: "device/zm1/MACMAC/state"
command_on_template: >
{"mac": "MACMAC"
{%- if brightness is defined -%}
, "brightness": {{ ((brightness-1) / 64 )|int +1 }}
{%- else -%}
, "brightness": 4
{%- endif -%}
}
command_off_template: '{"mac": "MACMAC", "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 -%}
homeassistant:
customize:
light.zm1_MACMAC_brightness:
friendly_name: 卧室M1亮度
sensor.zm1_MACMAC_temperature:
friendly_name: 卧室温度
sensor.zm1_MACMAC_humidity:
friendly_name: 卧室湿度
sensor.zm1_MACMAC_pm25:
friendly_name: 卧室PM2.5
sensor.zm1_MACMAC_hcho:
friendly_name: 卧室甲醛
|