Shell_command not working anymore after 0.48


I have a bash script to let an IP cam take a picture and mail it to me. The mailing part still works but removing and writing the new snapshot to the directory doesn’t:

  cam3snapshots: 'sudo bash /home/homeassistant/.homeassistant/script/'

Script (


rm -f /home/homeassistant/.homeassistant/snapshot/*.jpg

wget -q -O /home/homeassistant/.homeassistant/snapshot/cam01a.jpg http://USER:PW@IP:PORT/image/jpeg.cgi

When I execute the script manually I have no problem and the picture is saved in the right place. But when I trigger it via HA it doesn’t work. The previous pictures stay in the destination folder.
I’ve put the path where the script is located in the directory whitelist.




I did some more tests:

  test: 'sudo touch /home/homeassistant/.homeassistant/script/hass-shell-command-test'

When I execute the command in the terminal the file is created but when I use it in an automation nothing happens. Not even an error in the HA logs (as far as I can see).
It looks like HA can’t execute .sh anymore?

Again, it workerd before I upgraded to 0.48.

Can you help?


I messed around with a similar situation for a long time before I came to the conclusion that the running HA instance environment didn’t have any PATH variable defined so I had to explicitly state the absolute path to every element to make it work.
In my case I was using

date “+echo %b %d %Y”

and it just wouldn’t work.

I fixed it by changing the command to

/bin/date "+echo %b %d %Y"

and that worked fine.

So in your case I would try sudo /bin/bash…

Thank you for the reply but I don’t understand where to change to the complete path.
Is it in the script or in the shell_command line in the config yaml?


I am witnessing the same issues.

I have a shell command that uses sshpass to fire a script on my remote Mac to turn on MotionDetection with my CCTV system. Before 0.48 this command worked fine but now does not:

ss_arm: sshpass -f .macminipwd ssh -o StrictHostKeyChecking=no [email protected] 'osascript "/Users/media/SecuritySpy/SS_Arm_MotionCapture.scpt"'

I have now edited the command with the full path:

ss_arm: /usr/bin/sshpass -f /home/pi/.macminipwd ssh -o StrictHostKeyChecking=no [email protected] 'osascript "/Users/media/SecuritySpy/SS_Arm_MotionCapture.scpt"'

But it does not work. There is nothing in the logs. I can run this manually from the Pi command line and it works fine.

Any suggestions?

I changed the config to this but it still not working:

  cam3snapshots: 'sudo /bin/bash /home/homeassistant/.homeassistant/script/'

Works fine when I run it from the command line…

Can you try the following?

print_env: 'echo $PATH > ~/env.txt'

Tried that, nothing happens when you run it from within HASS

Is there anything in the logs? Did you turn up the log level?

Seems to work but I don’t see any env.txt on my Pi

2017-07-07 13:45:43 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1839284112: Received {'service': 'print_env', 'type': 'call_service', 'service_data': {}, 'domain': 'shell_command', 'id': 11}
2017-07-07 13:45:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=print_env, service_data=, domain=shell_command, service_call_id=1978787888-8>
2017-07-07 13:45:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978787888-8>
2017-07-07 13:45:43 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1839284112: Sending {'id': 11, 'result': None, 'type': 'result', 'success': True}

When I run it in the terminal I can find the env.txt but not if I run it from HA.

Anyone have any suggestions for a fix?

I got it now. The things I did was:

  • add pi user to sudoers
  • changed: cam3snapshots: ‘sudo bash /home/homeassistant/.homeassistant/script/’
    to: cam3snapshots: /bin/bash /home/homeassistant/.homeassistant/script/


1 Like

Great that it’s working now.

But as far as I can tell either should have been enough, depending on what’s in your actual script. If you add the user to sodoers you are allowed to run things with sudo, but then you removed the actual sudo command from your line, so either should be sufficient in my opinion. Could you check the the script runs without sudo rights too? Or do you actual need/use sudo within the actual script?

Btw. you can give sudo rights for single commands, which would reduce the risk.

When I only added the user to sudoers it didn’t work. After I changed the shell command it did…
No idea why but now it works again.


You may not even need sudo rights at all. But it all depends on whether you use sudo in the script itself.

And it stopped working after update 0.49…

Same problem: Running the script via command line = no problem, via HA = doesn’t work.


I found working solution for me in useful post of BarryHampants. The exact description in this quote - “I had a few problems, one was trying to use directories - ie/ shell_command: !include_dir_named shell_commands. I had no errors but once I changed from directories to shell_command: !include shell_commands.yaml my shell commands started actually firing rather than just pretending to fire.”
In my system (version 0.49) shell commands with irsend started to work.