- platform: command_line not accepted in automation.yaml

I like to send a command line command to an esp8266, but I can’t figure out what goes wrong can anybody tell me what is missing please?

this is what I do and what I get;

Code 1:

error 1:

17-01-30 14:33:39 homeassistant.util.yaml: while parsing a block collection
in “/home/hass/.homeassistant/schakelaars.yaml”, line 3, column 3
expected , but found ‘’
in “/home/hass/.homeassistant/schakelaars.yaml”, line 327, column 4
HA won’t start!

Attempt 2 - code:

platform: command_line
command_on: curl -k GET
command_off: curl -k GET
command_state: curl -k GET http://newKaku_65690900#1
value_template: ‘{{ value == “1” }}’
friendly_name: muurled

error 2: Logical one cause there are atleast 25 switches infront of this one (MQTT,

kaku protocoll)
HA won’t start!

17-01-30 14:36:04 homeassistant.util.yaml: expected ‘’, but found
in “/home/hass/.homeassistant/schakelaars.yaml”, line 315, column 1

Attempt 3 - code:

error 3: message in HA gui
Invalid config
The following components and platforms could not be set up:


Please check your config

But HA starts but no switch!

Without this code my automations run fine more then 20 switches!

First, your post is a little bit messy, please use the code tags for your entire configuration entries :slight_smile: If not, I can’t see if your indentation is correct.

A. Please make sure you didn’t declare a switch component in a automation component.

E.g, you can’t do:


automation: !include automation.yaml


     - platform: command_line

B. Also make sure you use command_line and not command-line

C. Enclose your commands in ’ or "

In utter despare I use switch: in switch.yaml, I started without it, That is why I did put a few of my affords as code snippets on my post.

I use spaces for indentation, and I don’t understand why when I use command_line in my yaml, the gui says command-line cause that is what the gui message tells me.

And sorry about being a bit messy!

Thanks for looking into my problem

O and the strange dot is - in my config

last config and I put this into my switch.yaml:

Just to be sure: you have included switch.yaml like this: :slight_smile:

switch: !include switch.yaml

I think you should try enclosing your command in ’ ’ or " " like this:

- platform: command_line
      command_on: 'ssh [email protected] power on'
      command_off: 'ssh [email protected] power off'
      command_state: 'ssh [email protected] power | grep -q "On"'

Sorry Stephan,

Yes I did the include like you type it, forgive me I am a newbie, and I seem to loose the format from my yaml when i paste it in here.

I did enclose the commands with '" but that didn’t work either?

no problem, use the </> button while selecting your yaml code

try this:

- platform: command_line
      command_on: 'curl -k GET'
      command_off: 'curl -k GET'
      command_state: 'curl -k GET http://newKaku_65690900#1'
      value_template: '{{ value == "1" }}'
      friendly_name: 'MuurLED'

You can also use http://www.yamllint.com/ for checking if your yaml is correct yaml.

Yes I did paste the snippet into yamllint and it came out with no errors.

I am restarting the service pasted your text into it. hopefully.

please tell me howto enter your code like you do into the grayed space with indetations correct, looks so dumb, and I already feel that way making so many newbie errors. ta

Oh I think enclosing your commands in ’ ’ solved the problem :wink:

  1. Lol first paste your yaml code
  2. Select your yaml
  3. press the </> button in the bar
  4. check indentation

Sorry no HA won’t start anymore!


17-01-30 22:39:35 homeassistant.util.yaml: expected ‘’, but found ‘’
in “/home/hass/.homeassistant/schakelaars.yaml”, line 310, column 1

that is line: - platform: command_line

check your other switches :wink: there maybe a typo, or forgotten closing "

did the whole 310 line big file pass yamllint?

Without this switch your or my text, no error occurs! All is fine and all switches work.

O by the way I work in nano!

Yes it did fit in yamllint and gave a valid yaml, I am lost Stephan

But if you dump the whole file in yamllint? Does it pass?

Because I can imagine editing your 310 line file in nano is a pain-in-the ass :smile:

Yes it did pass, gave me a valid yaml as answer! Only HA gives me an error and that is why I did this post I am stuck and don’t know what is missing or wrong, the code is valid in the tester.

ANd yes it hurts! :kissing_closed_eyes:

Well maybe you should split your switches further or recreate the whole config. Because somewhere in that file must be an error. Can you transfer your file to a more user-friendly editor like notepadd++ (be sure to replace tabs with spaces and set a tab to 2 spaces)

I check the file in notepad++

I guess there is something at fault within the command line protocol module in my HA, else I can’t explain.

I can add all kinds of protocols kaku, mqtt and others and all are already in it and working but whenever I put in only the platform name it crashes!!!???

what version are you on btw? the latest? command_line switch is working as a charm here (on latest) :wink:

what format are you using for the other entries in your switches.yaml?

Just try to following:

  1. paste the command_line switch in schakelaars2.yaml
  2. change your include in your main configuration.yaml to schakelaars2.yaml

this way you can make sure command_line switch is working

There you’ve got me cornered, i am on 0.35.0 waiting for 37.1 to roll out.
I heard a few comments about errors people had updating so I waited it out.

And being a newbie, gave me enough headaches to get it running in the first place, gui’s not starting, missing libraries I had a few things going wrong until I used the AIO, which ran. And it runs great until … command_line…

but you have to be 10000% sure that the whole file is correct; its easy to miss something in a file of 310 lines

As said when I leave out this snippet, it runs like a charm every automation, slide, protocol runs…
And even if I use a example snipped asking for let say a internal parameter, it crashes.

command_line kills it