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):

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

wifi:
  ssid: "myssid"
  password: "supersecret"
  manual_ip:
    static_ip: 0.0.0.0
    gateway: 0.0.0.0
    subnet: 255.255.255.0
    dns1: 0.0.0.0

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "Supersecretpassword"

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

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

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


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



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

https://community.home-assistant.io/t/esp8266-relay-active-low-how-to-prevent-triggering-on-boot-or-reset-solved/88279/5

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.

https://community.home-assistant.io/t/solved-esphome-opening-my-garage-door-when-the-esp32-restarts-including-after-an-esphome-update-to-the-esp32/619496/3

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!

Fixed!!

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:"

switch:
  - platform: gpio
    pin:
      number: GPIOXX
      inverted: true