I am not very good with ESPHOME and would like some expertise assistance if possible resolving my issue with my Lambda code, which is working but I cannot upgrade because the syntax is no longer valid, and as I copied the code, I cannot work out how to fix it.
output:
- platform: gpio
id: 'win_1'
pin: D2
- platform: gpio
id: 'win_2'
pin: D1
switch:
- platform: output
name: "win1"
output: 'win_1'
id: win1
- platform: output
name: "win2"
output: 'win_2'
id: win2
- platform: restart
name: "Bath Restart"
id: restart_bath
- platform: gpio
name: "Underfloor Heating"
pin: D7
inverted: True
cover:
- platform: template
name: "drawer Control"
id: win_open
optimistic: true
assumed_state: true
open_action:
- switch.turn_off: win2
- switch.turn_on: win1
- delay: 14s
- switch.turn_off: win1
close_action:
- switch.turn_off: win1
- switch.turn_on: win2
- delay: 14s
- switch.turn_off: win2
stop_action:
- switch.turn_off: win1
- switch.turn_off: win2
binary_sensor:
- platform: gpio
pin: RX
name: "Limit Switch"
device_class: door
on_release:
then:
- switch.turn_off: win2
- switch.turn_off: win1
- platform: gpio
pin: D5
name: "drawer Control Button"
filters:
invert:
on_press:
then:
- lambda: |
if (id(win_open).state == cover::COVER_OPEN) {
if (id(win1).state){
// drawer is opening
id(win_open).stop();
} else {
// drawer is open and not moving
id(win_open).close();
}
} else {
if (id(win2).state){
// drawer is closing
id(win_open).stop();
} else {
// win is closed and not moving
id(win_open).open();
}
}