ESP32 button (Garage Door) - cycles button press on power failure when power returns

Hi All, as per the title, I have a ESP32 set up with esphome for my garage doors (x2) - its as simple as configuring the button(s) in esphome/esp32 and connecting the pin outs on the esp32 to the pin outs on garage door motor where the physical button would be connected.
the problem I need help with is: when there’s a power outage (not very frequent), as soon the power comes back on and the esp32 powers back on it activates the button and my garage doors open (or close if already open) .
maybe it’s a self-start test/cycle or something? how do I stop this behavior?
my esphome config is below (hopefully it formats correctly):

  name: "garage-door-opener"
  platform: ESP32
  board: esp-wrover-kit

  ssid: "myssid"
  password: "supersecret"

# Enable logging

# Enable Home Assistant API

  password: "Supersecretpassword"

  - platform: status
    name: "Status Wifi Garage door 1 ESP32"
    id: etatWportail

  - platform: wifi_signal
    name: "WiFi Signal Garage door 1 ESP32"
    update_interval: 60s
    id: signalWportail

  - platform: restart
    name: "Restart Garage door 1 ESP32"

  - platform: gpio
    pin: 5
    id: output1
  - platform: gpio
    pin: 4
    id: output2

  - platform: output
    name: "Garage Door 1"
    output: output1
    duration: 500ms
  - platform: output
    name: "Garage Door 2"
    output: output2
    duration: 500ms

You may have a look at the options of the switch platform.

More specifically restore_mode could help you with your issue.

thank you, but I use buttons not switches - none of the options allow me to “install” to device, they all error

I use buttons and cant seem to get any of the solutions in this to even write to the device

Why not make them switches using platform gpio instead of buttons then you can add the restore_mode. You and turn them on then 500ms later turn them off when you want to open/close garage door.

okay, good idea, I will give that a try! thanks for your suggestion

Do both doors move or just door 1 ? GPIO5 is a strapping pin and gets PWM during boot.

Someone else had success with this.

I think both open, cant recall, I will check when I get home from work. I read that in some of the posts I came across too so I think I will set up a test bench with spare ESP32 and do some “lab tests” thanks again!


Long story short - I had to invert the switch with the below config (taken from ESPHOME)
I set it all up on bench with a multimeter and ran some tests etc…

" Active Low Switch

To create an active-low switch (one that is turned off by default), use the Pin Schema:"

  - platform: gpio
      number: GPIOXX
      inverted: true