How to have a push button instead of a switch for a relay

Hello…
I have one of those esp01 2 relay boards and i have it working just fine. But when i want to turn the relay on or off, i have to toggle the switch…
Is there a way to have just a button and it does trigger the on and short after the off again?
The logic what it does is in esphome…i would just need to trigger that routine

sun:
  latitude: 46.0931
  longitude: -72.8054

  on_sunrise:
    - elevation: 0.8°
      then:
        - switch.turn_on:
            id: relay1
        - delay: 20s
        - switch.turn_off: 
            id: relay1

  on_sunset:
    - elevation: -4°
      then:
        - switch.turn_on:
            id: relay2
        - delay: 20s
        - switch.turn_off: 
            id: relay2

You can use button, f.e.:

sun:
  latitude: 46.0931
  longitude: -72.8054

  on_sunrise:
    - elevation: 0.8°
      then:
        - button.press: button_on_sunrise

button:
  - platform: template
    id: button_on_sunrise
    name: Button on Sunrise
    on_press:
        - switch.turn_on:
            id: relay1
        - delay: 20s
        - switch.turn_off: 
            id: relay1

As well You can move auto_off logic directly to switch:

button:
  - platform: template
    id: button_on_sunrise
    name: Button on Sunrise
    on_press:
        - switch.turn_on:
            id: relay1

switch:
  - platform: gpio # or other
    id: relay1
    on_turn_on:
      - delay: 20s
      - switch.turn_off: 
          id: relay1

Now even using a switch it will go off after delay.

Cool thing…
Cause i was looking for, was to trigger the logic…
This will most likely work…
Will try this weekend when i have time…
Thx alot…

I tried it out and its awesome…
Thx a lot