Shell command doesnt work

im trying to make an automation that will take an image from the camera every 10 seconds for 5 minutes when motion is detected.

i think i found the right ffmpeg command:
ffmpeg -i rtsp://10.0.0.57/live/ch0 -vf fps=1/5 /home/hasamba/SavedImages/img%03d.jpg

i thought about making a shell command that will run this and then putting the shell command into an automation.

my problem is that for some reason i cannot see the shell command as an entity,
i put that in my confiuration.yaml:

shell_command:
  grab_image_from_kitchen_cam: 'ffmpeg -i rtsp://10.0.0.57/live/ch0 -vf fps=1/5 /home/hasamba/SavedImages/img%03d.jpg'

of course running this command from console works

if you have any other way of solving this ill be glad to hear,

thanks

Can you format your code (see blue bar on top of this page) to paste your code?

sorry, fixed

have you tried without the single quotes? Mines are without quotes.
Alternatively if that doesn’t work, as a test you can create a bash file with your command and have the shell_command point to the bash file (with full path), that will help confirm whether the issue is the command itself or the code in your yaml file…

i tried without the quotes.
ill try it with bash…thanks

My initial thought would be to try logging in as the HASS user (ha, hass, home-assistant, etc, …)

sudo su -s /bin/bash homeAssistantUser

and try running the command with that user to see if that works.

  • Other thoughts include using the full path to ffmpeg
  • Making sure the Home Assistant user has access to the /home/hasamba dir (it probably belongs to the home assistant user but the idea is there)

I hope one of them help
John

I was doing exactly this the last couple of days but I put that in a bash script on my RPi, not from HA.
What I found was, ffmpeg would just hang when running from script without the -nostdin option.
Hope that helps.

I’m not exactly sure what you are saying the problem is so I will answer based on what I THINK you are saying the problem is…

You won’t see an entity in your states table for a shell command. You should see a service exposed to allow you to run the shell command. you can try running the command from there to test if necessary.

Then you can use the id shown in the services section (i.e. shell_command.xx_xx…) in your automations.

thats exactly what i meant, thank,
now i see it in the services.

now for the other problem: it doesnt work…and if it will how do i stop it…

I’m not sure what you mean by “it doesn’t work”.

The automation doesn’t work or the shell command?

Or what you mean by “how to stop it”.

How to stop the automation from running or shell command from running in mid execution?

sorry for not being clear enough,
i meant that the shell command doesnt work and i didnt know how to stop the shell command in mid exection but i think i solve the two problems.

now i save the images inside homeassistant dir and it works, probably was a permission problem,
for the 2nd problem i found out how to stop with the right ffmpeg command.

thanks for all the help