This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Motion detector time limited deactivation
#2
Hi,

Try to use this when having a event based script with os.sleep:
Code:
-- Always start your script with this PID check to kill previous instance when needed
tpid = storage.get('PID:' .. _SCRIPTNAME)
if tpid == nil then
   pid = os.getpid()
   storage.set('PID:' .. _SCRIPTNAME, pid)
else
 pid = os.getpid()  
 storage.set('PID:' .. _SCRIPTNAME, pid)
 os.kill(tpid, signal.SIGKILL)
end

-- Put here your normal script with os.sleep()


-- End of script

-- Always end your script with removal of not needed storage data
storage.delete('PID:' .. _SCRIPTNAME)
BR,

Erwin
Reply


Messages In This Thread
RE: Motion detector time limited deactivation - by Erwin van der Zwart - 08.12.2018, 23:53

Forum Jump: