LogicMachine Forum
shutter timer based on detector - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: shutter timer based on detector (/showthread.php?tid=5873)



shutter timer based on detector - mariosp - 02.02.2025

Hello guys i need your help with a script!
i want if movement detector not trigger  after 5 minutes to close a a shutter but if trigger on with in the 5 minutes timer restarts 
anyone can help me ?
Thank You in advance !


RE: shutter timer based on detector - Daniel - 03.02.2025

https://kb.logicmachine.net/scripting/staircase-timer/


RE: shutter timer based on detector - admin - 03.02.2025

Also this: https://forum.logicmachine.net/showthread.php?tid=5700


RE: shutter timer based on detector - mariosp - 03.02.2025

(03.02.2025, 09:50)admin Wrote: Also this: https://forum.logicmachine.net/showthread.php?tid=5700

i only want the detector only to close it. 
Thank you in advance!


RE: shutter timer based on detector - admin - 03.02.2025

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