Struggling with command_line switch

I am trying to setup a simple switch to call either python or a shell script. Everything I try I have ended up with an invalid config. I can’t figure out what I am doing wrong, is it something with the user / virtual env?

I installed HomeAssistant on a raspberry pi following these instructions: https://home-assistant.io/docs/installation/raspberry-pi/

configuration.yaml:

switch:
platform: command_line
switches:
PC_Relay_Switch:
command_off: “sh /home/homeassistant/.homeassistant/test.sh”

Failed config
switch.command_line:
platform: command_line
switches: [source /home/homeassistant/.homeassistant/configuration.yaml:75]
PC_Relay_Switch: [source /home/homeassistant/.homeassistant/configuration.yaml:76]
command_off: sh /home/homeassistant/.homeassistant/test.sh

Successful config (partial)
switch.command_line:

looks like no caps allowed in the switch name.

In my switches.yaml I have…

- platform: command_line
  switches:
    backup_cmd:
      command_on:  bash /home/pi/.homeassistant/shell_scripts/backup_config.sh
      command_off: bash /home/pi/.homeassistant/shell_scripts/backup_config.sh

So I would try bash not sh also confirm that homeassistant user can execute the bash file.

or as a shell_command
backup_config: “bash /home/pi/.homeassistant/shell_scripts/backup_config.sh”

1 Like

yep all names have to lowercase and no spaces, only friendly names can have spaces and capitals :slight_smile: