homeassistant mqtt 参考

https://www.home-assistant.io/docs/mqtt/discovery/

https://www.bilibili.com/read/cv12453670/

https://www.wenjiangs.com/doc/home-assistant-component-mqtt

https://blog.csdn.net/qq_25886111/article/details/108880860

开关
switch:
  - platform: mqtt
    name: "Bedroom Switch"
    state_topic: "home/bedroom/switch1"
    command_topic: "home/bedroom/switch1/set"
    availability_topic: "home/bedroom/switch1/available"
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false
    qos: 0
    retain: true

变量说明:

name (可选): 名称,英文。默认 MQTT Switch
state_topic (必填): 获取设备值的MQTT topic
command_topic (必填): The MQTT topic to publish commands to change the switch state.
availability_topic (可选): 获取设备 birth&LWT 信息的 MQTT topic。如未指明,则设备的可用状态默认为 available;如指明,则设备的可用状态默认为 available。
payload_on (可选): 代表开启的值,默认 ON
payload_off (可选): 代表开启的值,默认 OFF
payload_available (可选): 代表设备在线状态的值, 如 ‘online’,默认为 ON
payload_not_available (可选): 代表设备离线状态的值, 如 ‘offline’,默认为 OFF
optimistic (可选): 设备是否在理想模式,如果 state_topic 没有定义,默认为 true
qos (可选): 最大 QoS 值,默认 0
retain (可选): 信息发布是否带 retain 标记
value_template (可选): 定制数据生成的模板