00_sprinkler:
fields:
stationA:
selector:
text:
name: stationA
description: First sprinkler station
required: true
time_to_run:
selector:
text:
description: Time in seconds for the station to run
name: time
required: true
sequence:
- action: opensprinkler.run_station
metadata: {}
data:
entity_id: '{{ stationA }}'
run_seconds: '{{ time }}'
alias: 'Script: Run Sprinkler'
description: 'Script: Run Sprinklers'
And I keep getting this error when the automation is triggered:
Executed: December 6, 2025 at 9:28:00 PM
Error: Error rendering data template: ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('time') | int }}' but no default was specified
If anyone can spot any error or flaw in the code above, please let me know.
Thanks.
In the automation you were using {{ input_number.sprinkler_staion01_time }} which the template engine interprets as a request for the property sprinkler_staion01_time of a variable object input_number… which you haven’t defined. If you want the state of the entity input_number.sprinkler_staion01_time, you need to use the states() function:
In this one you had the action using time, which is the name of the field, instead of time_to_run which is the variable ID:
00_sprinkler:
fields:
stationA:
selector:
text:
name: stationA
description: First sprinkler station
required: true
time_to_run:
selector:
text:
description: Time in seconds for the station to run
name: time
required: true
sequence:
- action: opensprinkler.run_station
metadata: {}
data:
entity_id: '{{ stationA }}'
run_seconds: '{{ time_to_run | int(0) }}'
alias: 'Script: Run Sprinkler'
description: 'Script: Run Sprinklers'
FWIW, starting an object ID with numbers ( like script.00_sprinkler) should be avoided since it can cause some annoying issues down the line…
@Didgeridrew if I want to input time for running sprinklers in minutes instead of seconds, how would it change the code “run_seconds: ‘{{ time | int(0) }}’”?
I tried few versions like “run_seconds: ‘{{ (time | int(0)) * 60 }}’” but the script always keeps giving an error.
Thanks!