Switch in HA only stays on for 1 second - ESPHome + Sonoff

Hello everyone,

I am using a Sonoff SV to power a low power led. The problem is that when I turn on the switch in Home Assistant, it will be on for 1 second and turn off. The leds itself stay turned on, so only the Home Assistant interface behaves strange. Does anyone know what goes wrong? When I am quick enough to tap the switch again in HA before it turns off itself, the led will listen to that command and turn off. Here’s my ESPHome code. Thank you.

esphome:
  name: verlichting_garagedeur
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pass

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Verlichting Garagedeur"
    password: "PASS"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
      
switch:
  - platform: gpio
    pin: GPIO12
    id: relay
  - platform: template
    icon: "mdi:lightbulb-on-outline"
    name: "Verlichting garagedeur"
    turn_on_action:
    - switch.turn_on: relay
    turn_off_action:
    - switch.turn_off: relay