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.

Light timer script
#2
os.sleep does not produce any CPU load. The problem is that each event runs separately and you can end with many copies running at the same time.

One of possible solutions:

Put the latest PIR trigger timer into storage (event script, add a check if PIR is ON):
Code:
storage.set('pir_timer', os.time())

Check timer expiration (resident script, tune sleep time as needed)
Code:
delta = os.time() - storage.get('pir_timer', 0)
if delta >= 120 then
  -- do some action here
end
Reply


Messages In This Thread
Light timer script - by Jayce - 26.07.2017, 08:51
RE: Light timer script - by admin - 26.07.2017, 10:03
RE: Light timer script - by Jayce - 26.07.2017, 11:15

Forum Jump: