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
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