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.

shutter timer based on detector
#5
Resident script with 0 sleep time. Modify input/output objects (0/0/1 and 0/0/3 in this example) and offvalue value as needed.
Code:
if not client then   timers = {     ['0/0/1'] = {       output = '0/0/3', -- output value object       timeout = 300, -- timeout in seconds       onvalue = nil, -- value to send when timer is turned on (nil to disable)       offvalue = true, -- value to send when timer is turned off (nil to disable)     },   }   function timerset(timer, value, ticks)     timer.ticks = ticks     grp.write(timer.output, value)   end   grp.sender = 'tm'   client = require('localbus').new(0.1)   client:sethandler('groupwrite', function(event)     local timer = timers[ event.dst ]     if timer and event.sender ~= grp.sender then       local value = tonumber(event.datahex, 16) or 0       if value == 1 then         timerset(timer, timer.onvalue, timer.timeout)       end     end   end) end client:loop(1) for _, timer in pairs(timers) do   if timer.ticks then     timer.ticks = timer.ticks - 1     if timer.ticks == 0 then       timerset(timer, timer.offvalue)     end   end end
Reply


Messages In This Thread
shutter timer based on detector - by mariosp - 02.02.2025, 19:31
RE: shutter timer based on detector - by admin - 03.02.2025, 12:53

Forum Jump: