Template Switch help

Hi, I need help with a template switch I can’t get working.

  - platform: template
    switches:
      opensprinkler_rain_delay:
        value_template: "{{ is_state('binary_sensor.rain_delay', 'on') }}"
        turn_on:
          service: shell_command.set_rain_delay_2
          data:
            delay_in_days: "{{ states('input_number.rain_delay_in_days') | int }}"
        turn_off:
          service: shell_command.set_rain_delay_2
          data:
            delay_in_days: 0

It’s the ‘turn on’ service that doesn’t work. It’s calling the shell command ->

set_rain_delay_2: “curl -G -v http://x.x.x.x/cv --data-urlencode pw=password --data-urlencode rd={{ delay_in_days }}”

I think the shell command is OK, as I can call it from the service panel with data {“delay_in_days”:“7”}, and it works.

Number input slider looks like this ->

  rain_delay_in_days:
    name: Slider
    initial: 0
    min: 0
    max: 7
    step: 1

Log ->
Error running command: curl -G -v http://x.x.x.x/cv --data-urlencode pw=password --data-urlencode rd={{ delay_in_days }}, return code: 3
NoneType: None

Any help appreciated

You need to use data_template instead of data because, well, you’re using a template. :wink:

        turn_on:
          service: shell_command.set_rain_delay_2
          data_template:
            delay_in_days: "{{ states('input_number.rain_delay_in_days') | int }}"

Oh of course, so I was just passing a string, thanks heaps