官网:https://www.home-assistant.io/components/fan.mqtt/
1 添加配置文件
要在安装中启用MQTT风扇,请将以下内容添加到您的configuration.yaml
文件中:
手动模式
# Example configuration.yaml entry
fan:
- platform: mqtt
name: "Bedroom Fan"
state_topic: "bedroom_fan/on/state"
command_topic: "bedroom_fan/on/set"
oscillation_state_topic: "bedroom_fan/oscillation/state"
oscillation_command_topic: "bedroom_fan/oscillation/set"
speed_state_topic: "bedroom_fan/speed/state"
speed_command_topic: "bedroom_fan/speed/set"
qos: 0
payload_on: "true"
payload_off: "false"
payload_oscillation_on: "true"
payload_oscillation_off: "false"
payload_low_speed: "low"
payload_medium_speed: "medium"
payload_high_speed: "high"
speeds:
- low
- medium
- high
添加后重启hass生效。
网友的设置,可参考
fan:
- platform: mqtt
name: "fengshan2"
state_topic: "home/fengshan/2/stat"
command_topic: "home/fengshan/2"
oscillation_state_topic: "home/fengshan/2/stat"
oscillation_command_topic: "home/fengshan2"
speed_state_topic: "home/fengshan/2/stat"
speed_command_topic: "home/fengshan/2"
retain: false
qos: 0
payload_on: "1"
payload_off: "0"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
payload_oscillation_on: "4"
payload_oscillation_off: "5"
speeds:
- low
- medium
- high
自动模式
将上述配置信息打包成 json包,发送给 配置话题,hass自动发现
- esp8266硬件受限制于mqtt库发送数据包有长度限制,没法一次性发送完。
- 可以用手机或电脑调试助手MQTT调试助手发送这个配置信息,他们能够发送的更长。
2 具体操作
登陆服务器
找到配置文件
添加风扇的信息
保存。
重启hass
hass开在某一个screen里面
找到这个背后screen,然后进去就是hass运行的命令窗口
连着三次 ctrl + c 关闭,重启