本帖最后由 jimmy802 于 2022-11-25 11:04 编辑
感谢贡献并分享,M1刷机并接入ha成功. 考虑再入手几个玩下
ha更新了mqtt格式,略做调整后自用模板,MACMAC也需替换
# Example configuration.yaml entry
mqtt:
sensor:
- name: 'zm1_MACMAC_temperature'
unique_id: zm1_MACMAC_temperature
# friendly_name: 温度
state_topic: 'device/zm1/MACMAC/sensor'
icon: 'mdi:thermometer'
unit_of_measurement: '°C'
value_template: '{{ value_json.temperature }}'
- name: 'zm1_MACMAC_humidity'
unique_id: zm1_MACMAC_humidity
# friendly_name: 湿度
state_topic: 'device/zm1/MACMAC/sensor'
icon: mdi:water-percent
unit_of_measurement: '%'
value_template: '{{ value_json.humidity }}'
- name: 'zm1_MACMAC_pm25'
unique_id: zm1_MACMAC_pm25
# friendly_name: PM25
state_topic: 'device/zm1/MACMAC/sensor'
icon: mdi:blur
unit_of_measurement: 'μg/m³'
value_template: '{{ value_json.PM25 }}'
- name: 'zm1_MACMAC_hcho'
unique_id: 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:
- name: zm1_MACMAC_brightness
unique_id: 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 -%}
|