Last night my tasmota based garage door opener died, and I decided to change to ESPHome. One thing that I really miss and cant figure out is how to get the moving state of the garage door, how do I know if I actually hit the button without waiting the 35seconds for the high lift garage door to trigger on the door open limit switch?
In tasmota i had states Closed, Opening, Open and Closing… and also Stopped once the function timed out after 35seconds without reaching the limit switch, but I think that gave warnings. these states seem to be reflected with the icons on my dashboard changing.
here is my current setup in ESPHome
switch:
- platform: gpio
pin:
number: D6
inverted: true
id: relay_pin
# If ESP reboots, do not attempt to restore switch state
restore_mode: always off
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_pin
binary_sensor:
- platform: gpio
pin:
number: D2
mode:
input: true
pullup: true
name: "Garage Door Open Reed"
id: open_switch
filters:
- delayed_on: 10ms
- delayed_off: 10ms
- platform: gpio
pin:
number: D1
mode:
input: true
pullup: true
name: "Garage Door Close Reed"
id: close_switch
filters:
- delayed_on: 10ms
- delayed_off: 10ms
cover:
- platform: template
name: "Garage Door"
device_class: garage
lambda: |-
if (id(close_switch).state) {
return COVER_CLOSED;
} else if (id(open_switch).state) {
return COVER_OPEN;
} else {
return {};
}
open_action:
- switch.turn_on: relay_pin
close_action:
- switch.turn_on: relay_pin
stop_action:
- switch.turn_on: relay_pin
optimistic: true
So thinking aloud an option would be to define a global, called Garage_State
and set the global using something along the lines of
garage door open reed → on press → set Garage_State = “open”
garage door open reed → on release → set Garage_State = “closing”
garage door close reed → on press → set Garage_State = “closed”
garage door close reed → on release → set Garage_State = “opening”
then for both of the on release start a 35sec timer, which when expires then set the state to stopped
I would also like some sort of interlock so if the state is opening or closing then the open and close actions wont work, only the stop action.
Is there a better way to do this? can it be done directly in the lambda?
the endstop cover is almost perfect, however i need to check the stop action and if it get triggered when a endstop is reached, perhaps setting the stop action to do nothing will work? but then how do i stop the door if something is in the way? and ideally send a notification if it doesnt open/close within the time limit… hmm