Help configuring timer value based on slider input value

I’ve created a timer and a slider, via helpers (see screenshot). I want the starting time of the timer to be updated by the value of the slider.

Ultimately, I’d like to use it to make an automation that will turn off the kids gaming devices in x minutes, where x is whatever I define on the slider.

Any advice out there on how to go about this?

To start a timer with a flexible duration you could use a script like this and call it via tap action:


script:
  start_gaming_countdown:
    alias: Gaming Countdown
    mode: single
    max_exceeded: silent

    sequence:
    - service: timer.start
      data_template:
        duration: "{{ states('input_number.gaming') |int * 60 }}"
      target:
        entity_id: timer.gaming

To define actions after the timer has finished, you can exploit the timer event data:

automation:
- id: gaming_countdown_end
  alias: Gaming Countdown End

  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.gaming

  action:
  - service: …

1 Like