Automation timer to turn off with input_number

Hi everyone,
I am trying to turn off a switch after a certain amount of seconds (so even 200 seconds) by selecting the time using an input_number, but I’m not successful so far as the automation does not trigger.
What am I doing wrong? Are seconds limited to 60 (so I’d better switch to minutes)?

many thanks!

automations.yaml:

- alias: Irrigation timer
  trigger:
  - entity_id: switch.balcony_irrigation
    for: 0:00:{{ states.input_number.irrigation_timer_duration }}
    platform: state
    to: 'on'
  action:
  - entity_id: switch.balcony_irrigation
    service: switch.turn_off
  initial_state: true

Mainly the problem is you didn’t specify the state properly. And you need to make sure it’s an integer. (An input_number can be a float.) At the very least you need:

    for: 0:00:{{ states.input_number.irrigation_timer_duration.state|int }}

But you should use the states() function. Also, you don’t need the 0:00: part. A single number is interpreted as seconds. So I’d suggest:

    for: "{{ states('input_number.irrigation_timer_duration')|int }}"
1 Like

Thank you so much it worked! Marked as solution :slightly_smiling_face:
what is the difference in using the states() function?

1 Like

Please read this including the warning.

1 Like

This is very very clear! Should have read more carefully in first instance…
Thank you!

1 Like