Beg somme help on an bash script launched on action

All kinds of 'OS' scripts
Post Reply
Posts: 1
Joined: Monday 26 June 2017 13:30
Target OS: Raspberry Pi
Domoticz version:

Beg somme help on an bash script launched on action

Post by dedalum » Monday 26 June 2017 13:56

Dear Domoticz experts :)

I would like to query some help on a problem that i am facing. I would first advise that I am really new on Domoticz and honestly not so much experimented on *nix families. So my issue might be quite boring for some of you (or even worse, the explanation on how to solve :oops: it)

Here i am using Domoticz on a Rpi3 (under RaspBian).
Goal of the script: I would like to capture a video (from a webcam) when a door is opened. To do that, I aim to use "streamer" which seems to work (well i still have to dig on streamer option, because i am not yet satisfied of the size of the captured video, or use ffmepg after the capture).
I have a sensor which indicates when the door is open: the signal is send periodically (let say each second). So, I created a switch that have a 2 seconds to be "off" (sorry i don't remember exactly the terminology used :oops: ).
On the "action ON" of the switch I want to start the capture, and stop it on the "action OFF". So, I put the call to the script with the expected parameter (ON or OFF) in the corresponding action fields.
As I expected Domoticz to "re-launch" each time the script at each sensor message "Door Open", I tried to solve it either putting the "streamer" in background, either using the "start-stop-daemon" command.

But unfortunately, it doesn't work as expected: I can see that a video file is being processed, and another etc... It seems that the "streamer" task is "killed?" and as the sensor is keeping sending the information, a new "streamer task" is restarted... I tried to watch the PID of streamer (with pgrep) and I can confirm that the PID changes (so it's not the "same task")

May I ask for some help here to indicate me if my script is wrong and how to correct it ?
I attach here two versions: the first one, which was "simple", but as I suspected Domoticz to stop the "shell used to start the script" I tried another one with the "start-stop-daemon" (I also tried to launch a batch to "double fork, but I am not sure of that was the good way to do that, and it doesn't worked at all)...
I have to say that here I am quite stuck and missing ideas for possible workarounds :roll:, so any advise would be welcomed…

Thanks in advance for any help or clues
    (1.2 KiB) Downloaded 73 times
    (1.08 KiB) Downloaded 61 times

    Post Reply

    Who is online

    Users browsing this forum: No registered users and 3 guests