Shell commands do not run

i am having problems getting shell commands to run. nothing at all will run

ive ran a test shell command from the front end and the file is not created:

  test: touch /tmp/hass-shell-command-test

my actual scenario is running a CL program, sky-remote-cli
it runs perfect from the command line

i have added my homeassistant user to the sudo group…groups homeassistant returns

pi@raspberrypi:~ $ groups homeassistant
homeassistant : homeassistant sudo audio gpio

my /etc/sudoers has the following entry:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

the CL program sky-remote-cli is located at:

pi@raspberrypi:~ $ whereis sky-remote-cli
sky-remote-cli: /usr/bin/sky-remote-cli /usr/local/bin/sky-remote-cli

calling the shell command from a scripts does not work either.
i have a sky.yaml located in a folder /.homeassistant/scripts/

    - service: shell_command.sky_playpause
    - service: shell_command.sky_power
    - service: shell_command.sky_record

my original setup had my shell_command .yaml files located in /.homeassistant/shell_command and my configuration.yaml had:

shell_command: !include_dir_merge_named shell_command

i tried a whole load of different permutations for the shell_command .yaml files, but nothing works.

im at my wits end with this!

if anyone can see something ive missed please put meout of my misery!!!

just a quick addition:
snippet from log file when i run a shell command from the frontend

17-05-15 21:46:55 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1766625104: Received {'type': 'call_service', 'id': 15, 'domain': 'shell_command', 'service': 'test', 'service_data': {}}
17-05-15 21:46:55 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=1978441840-12, domain=shell_command, service=test, service_data=>
17-05-15 21:46:55 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978441840-12>

I know you’ve noted that you have permissions set up for the user “homeassistant”, but have you tried sudo-ing to that user, as a test. See if you get any useful errors?

My install runs under the user ‘hass’

sudo su -s /bin/bash hass

and if your install runs in a venv, source it to make sure you’ve got things set up correctly within the virtual environment:

source /srv/hass/hass_venv/bin/activate

path/user will depend on your install.

Are you seeing errors in the home-assistant.log?

if i switch to my has user (homeassistant) and all works as it should:

pi@raspberrypi:~ $ sudo su -s /bin/bash homeassistant
homeassistant@raspberrypi:/home/pi $

i can run the sky-remote-cli and it works

i can then activate my v_env

homeassistant@raspberrypi:/home/pi $ source /srv/homeassistant/homeassistant_venv/bin/activate
(homeassistant_venv) homeassistant@raspberrypi:/home/pi $

and, again, the sky-remote-cli program works ok

Try with quotes around everything when you have spaces in the command. These are some of my shell_commands:

send_shutdown: 'curl -m 0.1 -s -o /dev/null -v > /dev/null 2>&1'
tv_channel_disney: 'ssh pi@irpi irsend send_once teliatv key_exit key_8 key_5'

putting quotes around the command did not work?!

Nothing in home-assistant.log?

What platform are you on? I wonder if it’s a bug with invoking shell?

I’m running in raspbian Jessie lite on a Pi3.

There is a snippet from the log in the OP, this is the only reference I can find to shell commands.

That’s a pretty standard deploy, so I doubt it’s a platform/OS issue.

That post from the first is from home-assistant.log? Sorry - it looked to me like the output to the shell.

If you’re not seeing an error that the shell_command failed, then HA thinks that it executed correctly.

Can you post a YAML snippet for how you’re passing arguments to sky-remote-cli in shell_command.sky_playpause, etc?

Yeah, that’s from the home assistant log.

Here is the shell command file sky_playpause.yaml

  sky_playpause: sudo -u pi -H /usr/bin sky-remote-cli pause

I have tried this with and without ' marks, and different permutations, eg with / without sudo
Which is called via a script, as posted above
(Config setup also explained)

I have also tried having

  name: do_this_here

directly in configuration.yaml and it does not work

Did you manage to get this working? I am experiencing the same problem.

im afraid not.

I have recently started fresh with my Pi’s, and so have a clean install of Jessie Lite and HAS, so once I have the main chunk of my config all setup I will try again with the shell commands

im having this issue when i make a shell script or python program and try to run it using shell command i get none type

Seems that shell command is executin process without shell. Its like crontab stuff (hardly to debug/figure whats worng).

Things to take into acount (Recomendations):

  • It is executed by homeassistant user, with their own rights (try test to execute before from console with this user)
  • Put all full path. I.e instead of “bash -c xxxx” use “/bin/bash -c xxxx”
  • The scripts has to have the shell program (i,e #!/bin/bash, perl, python etc…)
  • There arent Working-Directory. Put all full-path for files and directories for paramenters. For shell scripts, set the “cd directory” inside.
1 Like

This has worked for me: * Put all full path. I.e instead of “bash -c xxxx” use “/bin/bash -c xxxx”