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
#1
Hi

I have made a code that will deactivate a motion detector in a given time that can be set in the group objekt 3/6/9. After this time expires, the motion detector will be active, and recive a "motion not detected" command (a false writen to Forced_state 3/5/9, to reset motion status i the detector).

My problem is this: If i send a "true" to the Event adress for this script, then all works great. If i then send a "false" to the event adress, it does what i is supposed to do. But when i send a "True" once again, and do that before the os.sleep timer has run out of the preset time, then some strange things happends. It's like it's starting multiple os.sleep timers or something.
Is it possible to have the os.sleep "killed" when the event recives a "false"? Is os.sleep the right way to do this?


Code:
Lockdown_Event        = event.getvalue()
Lockdown        = grp.find    ('3/4/9')
Forced_State        = grp.find    ('3/5/9')
Forced_State_length    = grp.getvalue    ('3/6/9')

if Lockdown_Event == true
  then
     os.sleep(Forced_State_length)
     Lockdown       :write(false)
     Forced_State :write(false)
   else
     Forced_State :write(false)
end

BR
Kai-Roger
Reply


Messages In This Thread
Motion detector time limited deactivation - by Kai-Roger - 08.12.2018, 23:48

Forum Jump: