Use input_slider as input for trigger "for" function?

Hi,

I’m making a switch to control water irrigation so I would like to have it ON for set time then OFF.

I would like to use input_slider as input for “for” function in trigger as per below. Is it possible? How should I write it?

Please help. Thanks.

PS: I tried different way using template but it didn’t seem to work.

input_slider:
flower_timer:
name: Flower Timer
initial: 30
min: 0
max: 300
step: 10

automation:
- alias: Turn OFF when switch after set seconds
initial_state: True
hide_entity: True
trigger:
platform: state
entity_id: switch.flower
from: ‘off’
to: ‘on’
state: ‘on’
for:
seconds: "HERE IS WHERE I WANT TO USE INPUT FROM INPUT_SLIDER"
action:
service: homeassistant.turn_off
entity_id: switch.flower

Instead of for: I think you want to use delay:
You can use a template to specify the delay. Here is an example:
delay: '00:{{ states.input_slider.flower_timer.state | int }}:00'

1 Like

Yep, using delay within action: works great.
Thanks.

Is there still a way to use such a template for the seconds: command? The reason is, that I only want to trigger a specific automation, if a certain state persists for a certain amount of seconds.