Fixing ESPHome Script for Pulse Valve

Hello everyone,

I need some help fixing my ESPHome script. I am using a pulse valve for watering, which opens with a positive pulse and closes with a negative pulse. Here is the code I am currently using. In Home Assistant, I have two entities: one for turning it on and another for turning it off. However, I would like to have just one switch to control the valve and see its status.
Could anyone help me modify this to have just one switch to control the valve and see its status? Any suggestions or improvements are greatly appreciated.

Thank you!

Below is the code I am using:

esphome:
  name: ventil_erdbeeren
  friendly_name: ventil_erdbeeren

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "fYg2MsukDml+tuO9LqX59IrFcfFx"

ota:
  password: "d28de69d526d"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ventil-Erdbeeren"
    password: "sB0mLBykxBat"

captive_portal:

globals:
  - id: default_failsafe
    type: int
    restore_value: no
    initial_value: '2'  # default failsafe is 10 mins

switch:
  - platform: gpio
    pin: GPIO0
    id: ventil_erdbeeren_on
    name: "Ventil Erdbeeren On"
    restore_mode: ALWAYS_OFF
    
  - platform: gpio
    pin: GPIO2
    id: ventil_erdbeeren_off
    name: "Ventil Erdbeeren Off"
    restore_mode: ALWAYS_OFF 
    
  - platform: template
    name: "Ventil Erdbeeren"
    id: ventil_erdbeeren
    turn_on_action:
      - switch.turn_on: ventil_erdbeeren_on
      - delay: 50ms
      - switch.turn_off: ventil_erdbeeren_on
      - script.execute: failsafe
    turn_off_action:
      - switch.turn_on: ventil_erdbeeren_off
      - delay: 50ms
      - switch.turn_off: ventil_erdbeeren_off

sensor:
  - platform: wifi_signal
    name: "Wifi Ventil Erdbeeren"
    update_interval: 60s
    id: wifi_ventil_erdbeeren
    
script:
  - id: failsafe
    then:
      - delay: '00:10:00'
      - switch.turn_on: ventil_erdbeeren_off
      - delay: 50ms
      - switch.turn_off: ventil_erdbeeren_off

Use gpio output

or make your gpio switches internal: true

It works! Grate!

Thank you very much.