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.

not working script with timer
#1
Hello,

please help me find error. Task - when light in bathroom is off - i want swith on ventilation for 10 minutes. Found timer script at forum, but something is wrong in my script. Group 0/2/1 is 1 when light is Off and 0/2/1 is 0  when light is On. 6/0/1 and 6/0/2 switch On/Off ventilator. When light is off, ventilator starting but not switching off... May be problem is that 0/2/1 is always =1 till light is Off??

-- group address or name Vanna light on/off
addr = '0/2/1'
 
-- find required object
obj = grp.find(addr)
 
-- object exists and current state is "on"
if obj and obj.data then -- I think my problem is here but how to change correctly?
  -- delta is in seconds
  delta = os.time() - obj.updatetime
 grp.write('6/0/1', 1)
 grp.write('6/0/2', 1)
  -- switch off when timer expires
  if delta >= 10 * 60 then
    log(os.time())
  log(delta)
  log(obj.updatetime)
 grp.write('6/0/1', 0)
 grp.write('6/0/2', 0)
  end
end
Reply


Messages In This Thread
not working script with timer - by AlexLV - 24.04.2018, 18:15
RE: not working script with timer - by admin - 25.04.2018, 06:40
RE: not working script with timer - by AlexLV - 25.04.2018, 14:48
RE: not working script with timer - by admin - 25.04.2018, 15:13
RE: not working script with timer - by AlexLV - 25.04.2018, 15:21
RE: not working script with timer - by Daniel - 25.04.2018, 15:36
RE: not working script with timer - by AlexLV - 25.04.2018, 16:22

Forum Jump: