Hello,
(I am new to HA, (running it on HAOS in proxmox)
TLDR;
a shell command (running a shell script) seems stopped after few seconds (i assume 3) when in an automation, but not when run in a terminal (in the homeassistant docker) or when executed via “dev tools → action”
My intent is to capture an video from usb webcam when a sensor is activated, and stop it when the sensor is deactivated.
I read that scripts (not sure if this is also for shell scripts) are limited to 60 seconds, i am fine with it, it is ok to have a capture "from sensor “on” till 50 seconds or sensor has been switch to “off”
To do that, i created a shell script (in /config/scripts) with ON or OFF parameter. Basically:
if ON:
'nohup ffmpeg -i /dev/video0 -codec:v vp9 -qp 0 -preset ultrafast -t 50 /media/capture.mp4 &
if Off
S_PID=`pgrep "ffmpeg"`
kill -s SIGTERM $S_PID
in configuration.yaml, i added :
shell_command:
usb_camera_record_on: /config/scripts/script_door_HA.sh ON
usb_camera_record_off: /config/scripts/script_door_HA.sh OFF
I also “wrap them” into scripts (in scripts.yaml)
usb_camera_start_record:
alias: USB Camera start recording
mode: parallel
sequence:
- action: shell_command.usb_camera_record_on
usb_camera_stop_record:
alias: USB Camera stop recording
mode: parallel
sequence:
- action: shell_command.usb_camera_record_off
Now, when i use either the shell commands or the scripts in “dev tools”->action, this work nicely:
when i start a capture and do nothing, i have a 50 seconds movie
when i start a capture, and start another action to stop it (shell command or script), i have a shorter movie.
This is also the same when i lunch those scripts from ssh (in the homeassistant docker)
That’s fine… but when i start the capture from an automation, (e.g. trigger when sensor is “on”) i only have a movie of 2 to 3 seconds (max).
I am stuck here and i would appreciate any hints
I seen post and docs regarding the execution time of scripts, i don’t intent to stress the paradigm of “less than a minute”, but i would like to be able to record more or less 50 seconds…
I try to remove the “nohup” and “&” but… no success…
Sorry if this is a “dumb” question, but i fail to find something related to this…
Thanks for reading and for any possible hints…
regards,
D