Helper Input number & Script

Hi all,
I am having a challenge with using the input number obtained from helper and executing script.

This is script is supposed to Turon on one zone in my irrigation system that is connected to the tap used to refill the swimming pool.

I have a few scripts that work with fixed refill time and they are:

alias: 60 minutes
sequence:
  - service: rachio.start_multiple_zone_schedule
    target:
      entity_id: switch.pool
    data:
      duration: 60
mode: single
icon: hass:water

This basically refills the pool for 60min.

Now I have created a helper
1

And then have created a script in order to execute based on the helper value:

alias: Refill Pool xx Min
sequence:
  - service: rachio.start_multiple_zone_schedule
    target:
      entity_id: switch.pool
    data:
      duration: input_number.pool_refill_time.state
mode: single
icon: hass:water

3

and now I am gerring an error :cry:

Failed to call service script/1628271212251. invalid literal for int() with base 10: ‘input_number.pool_refill_time.state’

I have tried the template like this:

{{states.input_number.pool_refill_time.state}}

alias: Refill Pool xx Min
sequence:
  - service: rachio.start_multiple_zone_schedule
    target:
      entity_id: switch.pool
    data:
      duration: {{states.input_number.pool_refill_time.state}}
mode: single
icon: hass:water

then I got the error:
Failed to call service script/1628271212251. int() argument must be a string, a bytes-like object or a real number, not ‘dict’

and

{{states.input_number.pool_refill_time.state | int}}

and

{{states.input_number.pool_refill_time.state | float}}

errors are the same:
Failed to call service script/1628271212251. int() argument must be a string, a bytes-like object or a real number, not ‘dict’

Please help :cry:

Templates need to be enclosed in quote marks.

alias: Refill Pool xx Min
sequence:
  - service: rachio.start_multiple_zone_schedule
    target:
      entity_id: switch.pool
    data:
      duration: '{{ states("input_number.pool_refill_time") }}'
mode: single
icon: hass:water
3 Likes

:man_facepalming:
so many things I tried, even double quoting template and it didn’t work

100% correct, and Thank you so so very much, it was the quotes :slight_smile:

‘template’ instead of “template”

:blush:

You can use either ' or " to enclose the templates, you just need to be sure that they are applied correctly…

This would also work:

duration: "{{ states('input_number.pool_refill_time') }}"

But, the following would not, because the inner and outer quote marks interfere with one another:

duration: "{{ states("input_number.pool_refill_time") }}"
1 Like