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.

Presence sensor - Reset timer/delay
#1
Hi,

I am struggling getting a script related to a presence sensor to work. I have made an event based script, but it does not turn out the way I like.

value = event.getvalue()
val1 = 15
if value == true then
  grp.write('2/2/2', 1)
elseif value == false then
  os.sleep(300)
  grp.write('2/2/2', 0)
end

If the presence sensor (1/1/1) is triggered and writes a 1, then I would like the light (2/2/2) to be turned on.
When presence is no longer detected it writes a 0, and I would like the light to be turned off. However, I do not want the light to be turned of straight away, I would like to wait 5 min before the light is turned off. 
So far so good...
This is where I am struggling, if presence again is detected before the 5 min expires, the presence sensor writes another 1. However, the previous script is still running so the light gets turned off before the last 5 min expires.

I would like a solution where another 1 from the presence detector resets the timer. So if someone constantly walks in and out of the room within a time frame of less then 5 minutes, then the light constantly stays on.

I am not sure if an event based script is the way to go...
BR
Mr. D
Reply


Messages In This Thread
Presence sensor - Reset timer/delay - by Mr.D - 14.04.2017, 21:18

Forum Jump: