Issue with command line switch

Hi all, really need help with getting a command line switch to work, the code I’ve got from the forum is probably a couple years old and my best guess is it’s depreciated ?

Basically the switch won’t even show on my HA instance which I’d expect should be at “switch.aquariumledmanual”

The code I’m using in a file in config is

switch:
  - platform: command_line
    switches:
      aquariumledmanual:
       friendly_name: Handmatige LED bediening
       command_off: 'curl -X POST -k -H "Content-Type: application/x-www-form-urlencoded" -d "action=14cswi=false" http://10.0.76.2/stat'

Any help appreciated :pray:

Always check the latest docs. The config has changed recently.

Still don’t get it, sorry I don’t usually use commands, don’t really understand all the stuff in the quotes as it is lol

In the link from @Troon you can find also an example:

# Example configuration.yaml entry
command_line:
  - switch:
      name: Kitchen Light
      command_on: switch_command on kitchen
      command_off: switch_command off kitchen

Take this example and adapt it with your data.

That’s a config.yaml example, works differently when it’s in a different yaml file

The syntax is the same regardless of what file you use. Important thing is that your configuration.yaml file is properly referencing your file, and the yaml syntax is correct. Your original layout is not correct.

Thanks all for help, took it out the file and moved to command_line.yaml and formatted above and thus far I think it may be working :pray:

1 Like