08.12.2018, 23:48
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?
BR
Kai-Roger
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