Command_line problems with switch and sensors

Hi, im having problems with a switch command_line. Currently I have this code:

  platform: command_line
      command_on: 'echo "1">my_switch'
      command_off: 'echo "0">my_switch'
      command_state: 'cat my_switch'
      value_template: '{{ value ==1 }}'
      command_on: "curl -i -m 1 http://xxxxx  -s "
      command_off: "curl -i -m 1 http://xxxxx  -s"
      value_template: '{{ return_value == "" }}'

I have Hasbian image on a RPI2
when I toggle the switch the command is executed successfuly, the curl is reported on my webserver, but no my_switch file gets created, or any other component that uses command_line it generates the following error.

homeassistant.components.switch.command_line: Command failed:

for the test and ep: so the sensor always returns to off.
Checked with my standard user executing these commands doing a su to homeassistant user and it executes with no problem

Also have a sensor


  • platform: command_line
    command: “grep -c ‘invalidpassword’ /home/homeassistant/.homeassistant/home-assistant.log”
    name: badlogin

also reports

homeassistant.components.sensor.command_line: Command failed: grep -c ‘invalidpassword’ /home/homeassistant/.homeassistant/home-assistant.log

My intuition suggests that it is a problem with the execution rights of the user of hassbian. Any ideas with this ??



Found some info that I think will help. Maybe someone has the same problem.
The hasbian image runs with homeassistant user, and by default runs command_line commands using a default / path, naturally, the echo on the file failed.

For the other messages added the /usr/bin/curl for the command, still failed. although it works fine at / with homeassistant user su. Still puzzled by this one, although will use a bash script to change status on a file (with proper permissions).

If I find anything will update.