本帖最后由 ptlzx 于 2022-11-15 20:22 编辑
早期使用了Sonoff开关调用了MQTT,现在写法要求更新,我原来的写法如下,请教大神如何修改可以在新版HA中使用(多个switch开关),谢谢!
configuration.yaml内容如下:
switch:
- platform: mqtt
name: "Sonoff_1"
state_topic: "stat/S1/POWER"
command_topic: "cmnd/S1/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
- platform: mqtt
name: "Sonoff_2"
.........
homeassistant新文档要求按以下格式,不知道具体怎么改,麻烦大神帮改下代码。感谢
https://www.home-assistant.io/integrations/switch.mqtt/#new_format
# Example configuration.yaml entry
mqtt:
switch:
- command_topic: "home/bedroom/switch1/set"
改了下这样不知道有没错,怕把HA给整奔溃了,确认下(S1、S2是topic)
mqtt:
switch:
- unique_id: S1
name: "Sonoff_1"
state_topic: "home/bedroom/S1"
command_topic: "home/bedroom/S1/set"
availability:
- topic: "home/bedroom/S1/available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
- unique_id: S2
name: "Sonoff_2"
state_topic: "home/bedroom/S2"
command_topic: "home/bedroom/S2/set"
availability:
- topic: "home/bedroom/S2/available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
|