我用的Sonoff Dual,ESPHome配置文件如下
esphome:
name: projector_curtain
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
use_address: 192.168.19.87
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "South Balcony Cover"
password: !secret ap_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: GPIO10
inverted: true
id: button
on_press:
then:
# logic for cycling through movements: open->stop->close->stop->...
- lambda: |
if (id(my_cover).current_operation == COVER_OPERATION_IDLE) {
// Cover is idle, check current state and either open or close cover.
if (id(my_cover).is_fully_closed()) {
id(my_cover).open();
} else {
id(my_cover).close();
}
} else {
// Cover is opening/closing. Stop it.
id(my_cover).stop();
}
switch:
- platform: gpio
pin: GPIO12
interlock: &interlock [open_cover, close_cover]
id: open_cover
- platform: gpio
pin: GPIO5
interlock: *interlock
id: close_cover
cover:
- platform: time_based
name: "Projector Curtain"
id: my_cover
open_action:
- switch.turn_on: open_cover
open_duration: 46s
close_action:
- switch.turn_on: close_cover
close_duration: 46s
stop_action:
- switch.turn_off: open_cover
- switch.turn_off: close_cover
|