Relays as 5 second buttons

Hi there, kind of new to the whole home assistant - ESP32 combo. Love it though.
I automated my old 12V intercom system (Siedle) with an ESP32 board and a 4 port relay.
With some soldering and some effort I am now able to open the front gate, front door, put on lighting and power the “flood-lights” in case a zombie apocalypse takes place. :slight_smile:
It is a relay on relay situation for the lights.

My current ESP32 config for the buttons:

esphome:
  name: esp-doorbitch-guesthouse

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxx"

ota:
  password: "xxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Doorbitch-Guesthouse"
    password: "xxxxxxxxxxxx"

captive_portal:
    
switch:
  - platform: gpio
    pin: 
      number: 16
      inverted: true
    name: "Huisdeur buzzer"
    id: IN1  
  - platform: gpio
    pin: 
      number: 17
      inverted: true
    name: "Licht oprit" 
    id: IN2
  - platform: gpio
    pin: 
      number: 18
      inverted: true
    name: "Flood lights"
    id: IN3  
  - platform: gpio
    pin: 
      number: 19
      inverted: true
    name: "Hekdeur buzzer" 
    id: IN4

But as you probably can decode I now have toggle buttons all around.
It would be better if the relays would close the circuit for 5 seconds and the open again.
And if it would be possible it would be great if it could also (virtually) remember if the floodlight is turned on or of.

Could anyone point me in the right direction?

Thanks a lot.
Pepper662

Please post your yaml correctly. See How to help us help you - or How to ask a good question

Wouldn’t it be better to use the momentary switch or buttons?