Command line platform: Command with template

Hi

Is there any option to have a command string dynamicall built using a template for command_line switch (Command line Switch - Home Assistant).

Currently I have this:

switch:
  - platform: command_line
    switches:
      something_change_value:
        command_on: curl -s "http://localhost:123/do?value=12"
        command_off: curl -s "http://localhost:123/do?value=0"

Now I want the 12 to be dynamic from a input_number

switch:
  - platform: command_line
    switches:
      something_change_value:
        command_on: "{{ curl -s http://localhost:123/do?value=  + states.input_number.myValue.state | round(0)  | string }}"
        command_off: curl -s "http://localhost:123/do?value=0"

the config is valid, but it does not evaluate my template when executed

How has to so be done?

No, it only accepts strings, not templates:

What you can do is create two shell commands, they do accept templates.

Then use your shell commands as the on/off actions in a template switch:

The shell commands are services.

1 Like

Wow, thanks a lot. Works perfectly.

1 Like