How can I use curl from an automation?

Please first format the lines from your configuration and automations files so we can read them properly. The easiest way to do that is to select the lines then hit the </> button. This is very important because YAML is very sensitive to indentation, and also without proper formatting certain characters (like quotes and dashes) get changed, as you can see by looking at your post above. Once we’re able to see your YAML code correctly we’ll be able to help.

Having said that, best I can tell is that you need to change your shell_command to:

shell_command:
  ac_on: "curl -X POST -d '{{ data }}' {{ url }}"

and the corresponding automation action should be:

action:
  - service: shell_command.ac_on
    data:
      url: 'http://192.168.1.192/SystemON'
      data: '{"SystemON":"on"}'

UPDATE: Wow, just saw this again. Must not have know what I was doing back then! :blush: Updated the data_template to data, since data_template isn’t required here.

4 Likes