『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 1210|回复: 3

[求助] hass升级了,m1的配置文件配置出了问题

[复制链接]

2

主题

30

帖子

220

积分

中级会员

Rank: 3Rank: 3

积分
220
金钱
190
HASS币
0
发表于 2023-3-22 19:08:57 | 显示全部楼层 |阅读模式
升级到新版本的hass后,原来关于m1的配置文件报错,问题出在mqtt的语法上,按官方提示修改了一下,MQTT Sensor - Home Assistant (home-assistant.io),结果5个实体,现在只有2个,分别是亮度和甲醛,别个温度,温度和pm2.5不出来,不知道哪里还要修改,麻烦大侠们指导一下,感谢。

mqtt:
sensor:
   name: 'zm1_b0f893117373_temperature'
   unique_id: zm1_b0f893117373_temperature
   # friendly_name: 温度
   state_topic: 'device/zm1/b0f893117373/sensor'
   unit_of_measurement: '°C'
   icon: 'mdi:thermometer'
   value_template: '{{ value_json.temperature }}'

   name: 'zm1_mac_humidity'
   unique_id: zm1_mac_humidity
   # friendly_name: 湿度
   state_topic: 'device/zm1/mac/sensor'
   unit_of_measurement: '%'
   icon: mdi:water-percent
   value_template: '{{ value_json.humidity }}'

   name: 'zm1_mac_pm25'
   unique_id: zm1_mac_pm25
   # friendly_name: PM25
   state_topic: 'device/zm1/mac/sensor'
   unit_of_measurement: 'μg/m³'
   icon: mdi:blur
   value_template: '{{ value_json.PM25 }}'

   name: 'zm1_mac_hcho'
   unique_id: zm1_mac_hcho
   # friendly_name: 甲醛
   state_topic: 'device/zm1/mac/sensor'    unit_of_measurement: 'mg/m³'
   icon: mdi:chemical-weapon
   value_template: '{{ value_json.formaldehyde }}'

light:
   name: zm1_mac_brightness
   unique_id: zm1_mac_brightness
   schema: template
   command_topic: "device/zm1/mac/set"
   state_topic: "device/zm1/mac/state"
   command_on_template: >
     {"mac": "mac"
     {%- if brightness is defined -%}
     , "brightness": {{ ((brightness-1) / 64 )|int +1 }}
     {%- else -%}
     , "brightness": 4
     {%- endif -%}
     }
   command_off_template: '{"mac": "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 -%}



homeassistant:
customize:
   light.zm1_mac_brightness:
     friendly_name: zM1亮度
   sensor.zm1_mac_temperature:
     friendly_name: zM1温度
   sensor.zm1_mac_humidity:
     friendly_name: zM1湿度
   sensor.zm1_mac_pm25:
     friendly_name: zM1 PM2.5
   sensor.zm1_mac_hcho:
     friendly_name: zM1甲醛

回复

使用道具 举报

77

主题

1391

帖子

2万

积分

元老级技术达人

积分
24331
金钱
22900
HASS币
290
发表于 2023-3-22 19:19:24 | 显示全部楼层


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 -%}


用我的给你参考一下吧
回复

使用道具 举报

0

主题

2

帖子

44

积分

新手上路

Rank: 1

积分
44
金钱
42
HASS币
0
发表于 2023-3-23 01:50:28 | 显示全部楼层
dscao 发表于 2023-3-22 19:19
用我的给你参考一下吧

感谢大佬,正愁M1咋整呢
回复

使用道具 举报

2

主题

30

帖子

220

积分

中级会员

Rank: 3Rank: 3

积分
220
金钱
190
HASS币
0
 楼主| 发表于 2023-3-23 14:21:34 | 显示全部楼层
感谢,换了mac地址就来了,其实看上去代码结构没发生质变,但确实 就是不兼容了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 23:54 , Processed in 1.152213 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表