Page 1 of 1

Delay for PIR?

Posted: Friday 13 March 2020 14:08
by johansson
I've a couple of motion detectors that send snapshots to Telegram when motion is detected. The basic setup works nicely, but motion is detected a bit too far away: how to add a delay in dzvents scrip?

The current script below. Eg, adding ".afterSec(1)" after the os.execute does not work.

Code: Select all

return {
	on = {
		devices = {
			'Motion detector 1',
		}
	},
	execute = function(dz, device)
 local securityArmed = (dz.security == dz.SECURITY_ARMEDAWAY or dz.security == dz.SECURITY_ARMEDHOME)
        if device.active and securityArmed then 
   		os.execute('sudo /home/folder/to/scripts/snapshot.sh &')

end
end
}
Another option would also be recording a short video clip to my Raspberry in addition to the snapshot, but that I couldn't figure out either.

Any ideas? Thanks in advance.

Re: Delay for PIR?

Posted: Friday 13 March 2020 14:55
by waaren
johansson wrote: Friday 13 March 2020 14:08 I've a couple of motion detectors that send snapshots to Telegram when motion is detected. The basic setup works nicely, but motion is detected a bit too far away: how to add a delay in dzvents script?
If the delay is only 1 second, my approach would be

Code: Select all

return {
    on = {
        devices = {
            'Motion detector 1',
        }
    },
    execute = function(dz, device)
        local securityArmed = (dz.security == dz.SECURITY_ARMEDAWAY or dz.security == dz.SECURITY_ARMEDHOME)
        if device.active and securityArmed then 
            os.execute('sleep 1; sudo /home/folder/to/scripts/snapshot.sh &')
        end
    end
}

Re: Delay for PIR?  [Solved]

Posted: Friday 13 March 2020 15:38
by johansson
Oh yes, simple and beautiful! Works like charm, thanks a bunch.