Home Assistant 2022.9.0以后的版本升级了MQTT格式,抽空把升级了下自己的配置文件,顺便做个记录
新旧对比
拿ztc1的MQTT来举个例子
旧版
代码语言:javascript复制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'
新版
代码语言:javascript复制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'
差别
旧版
代码语言:javascript复制switch:
- platform: mqtt
name: 'ztc1_1_xxxxxxxxxxxx'
其他参数: 参数值
新版
代码语言:javascript复制mqtt:
switch:
- name: 'ztc1_1_xxxxxxxxxxxx'
其他参数: 参数值