Use some kind of boolean to activate functionality

Hello,

I have a light which automatically turns off after 10 minutes, This is great however in some scenarios I want to disable this functionality.
I want parameters to be stored on esphome so if HA is down, the functionality still works.
I tried “globals” but it turns out I can’t set those manually, So now I’m at the template switch.
So I have this.

switch:
  - platform: template
    id: enable_timer
    name: "Enable Timer"
    restore_mode: ALWAYS_ON
    turn_on_action:
      - script.execute: turn_off_timer
    turn_off_action:
      - script.stop: turn_off_timer
  - platform: gpio
    pin: GPIO27
    name: ${switch_name}
    id: light_1
    icon: "mdi:lightbulb"
    on_turn_on:
    - light.turn_on: stat_led
    - if:
        condition:
          switch.is_on: enable_timer
        then:
          - script.execute: turn_off_timer
    on_turn_off:
    - light.turn_off: stat_led
    - if:
        condition:
          switch.is_on: enable_timer
        then:
          - script.stop: turn_off_timer

turn_on_action and turn_off_action are required, but I should be able to do without.

now the switch is exposed in HA.
image
but I’m unable to turn in on, the toggle turns itself off after 1 sec and nothing gets added in the logbook.

I actually think I’m going the wrong way here, but I can’t find how this actually should work.

ok this seems to work

switch:
  - platform: gpio
    pin: 33
    id: enable_timer
    name: "Enable Timer"
    restore_mode: ALWAYS_ON
    on_turn_on:
      - script.execute: turn_off_timer
    on_turn_off:
      - script.stop: turn_off_timer
  - platform: gpio

But I think there should be a way without a dummy gpio