Home Assistant 2022.9.0以后的版本升级了MQTT格式,抽空把升级了下自己的配置文件,顺便做个记录

新旧对比

拿ztc1的MQTT来举个例子

旧版

switch:
  - platform: mqtt
    name: 'ztc1_1_xxxxxxxxxxxx'
    unique_id: ztc1_1_xxxxxxxxxxxx
    state_topic: 'device/ztc1/xxxxxxxxxxxx/state'
    command_topic: 'device/ztc1/xxxxxxxxxxxx/set'
    payload_on: '{"mac":"xxxxxxxxxxxx","plug_0":{"on":1}}'
    payload_off: '{"mac":"xxxxxxxxxxxx","plug_0":{"on":0}}'
    value_template: '{{ value_json.plug_0.on }}'
    state_on: '1'
    state_off: '0'

新版

mqtt:
    switch:
      - name: 'ztc1_1_xxxxxxxxxxxx'
        unique_id: ztc1_1_xxxxxxxxxxxx
        state_topic: 'device/ztc1/xxxxxxxxxxxx/state'
        command_topic: 'device/ztc1/xxxxxxxxxxxx/set'
        payload_on: '{"mac":"xxxxxxxxxxxx","plug_0":{"on":1}}'
        payload_off: '{"mac":"xxxxxxxxxxxx","plug_0":{"on":0}}'
        value_template: '{{ value_json.plug_0.on }}'
        state_on: '1'
        state_off: '0'

差别

旧版

switch:
  - platform: mqtt
    name: 'ztc1_1_xxxxxxxxxxxx'
    其他参数: 参数值

新版

mqtt:
    switch:
      - name: 'ztc1_1_xxxxxxxxxxxx'
        其他参数: 参数值
最后修改:2023 年 02 月 11 日
如果觉得我的文章对你有用,请随意赞赏