请大佬们帮忙测试下这个风扇代码是哪里出错了,保留风扇的机械开关。HA内控制继电器没问题,风扇能换档。物理开关只能在断电后控制一次继电器换档,之后binary_sensor 的状态会一直保持 启动,物理开关就会失效无法控制。
esphome:
name: d1_mini
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "7972b2158b53edab7f6528"
wifi:
ssid: "tp6236"
password: "95698263"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "d1_mini Fallback Hotspot"
password: "kfnJHYTxQuQL"
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: 12
inverted: true
name: "Fan Local Control Speed 1"
id: "fan_local_1"
icon: "mdi:fan-speed-1"
filters:
- delayed_on: 500ms
- delayed_off: 500ms
on_press:
then:
- switch.turn_on: speed1
on_release:
then:
- switch.turn_off: speed1
- platform: gpio
pin:
number: 13
inverted: true
name: "Fan Local Control Speed 2"
id: "fan_local_2"
icon: "mdi:fan-speed-2"
filters:
- delayed_on: 500ms
- delayed_off: 500ms
on_press:
then:
- switch.turn_on: speed2
on_release:
then:
- switch.turn_off: speed2
- platform: gpio
pin:
number: 14
inverted: true
name: "Fan Local Control Speed 3"
id: "fan_local_3"
icon: "mdi:fan-speed-3"
filters:
- delayed_on: 500ms
- delayed_off: 500ms
on_press:
then:
- switch.turn_on: speed3
on_release:
then:
- switch.turn_off: speed3
switch:
- platform: gpio
pin: 16
interlock: &interlock_group [speed1, speed2, speed3]
interlock_wait_time: 1000ms
name: "Fan Speed 1"
icon: "mdi:fan-speed-1"
id: "speed1"
inverted: true
- platform: gpio
pin: 5
interlock: *interlock_group
interlock_wait_time: 1000ms
name: "Fan Speed 2"
icon: "mdi:fan-speed-2"
id: "speed2"
inverted: true
- platform: gpio
pin: 4
interlock: *interlock_group
interlock_wait_time: 1000ms
name: "Fan Speed 3"
icon: "mdi:fan-speed-3"
id: "speed3"
inverted: true
|