LogicMachine Forum
function from timer - 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: function from timer (/showthread.php?tid=6517)



function from timer - Danny - 22.07.2026

Dear readers,

I have a timer that receives a virtual group address via a value of 0-100%.

As soon as this value exceeds 1 percent, the timer's value must be sent to 1/0/1, and I also need to activate a switching actuator on group addresses 1/1/1 through 1/1/7.
As soon as the timer's value reaches 0%, the switching actuator must also turn off.

Can someone help me with this?

Thanks


RE: function from timer - admin - 22.07.2026

Can you explain the 1% logic? If the timer value is 1 then nothing should happen or should it turn on the actuators?

If 0 = off, 1..100 = on then the following script should do what you need.
Code:
value = event.getvalue() on = value > 0 if on then   grp.checkwrite('1/0/1', value) end for i = 1, 7 do   grp.checkwrite('1/1/' .. i, on) end



RE: function from timer - Danny - 22.07.2026

Thanks for this script; 
I modified it slightly because I don't need to send commands to consecutive group addresses.
The script works with the switching commands, but when I send 0%, it doesn't transmit that value—though it does transmit anything above 1%.
Code:
value = event.getvalue() on = value > 0 if on then   grp.checkwrite('1/0/1', value) end addresses = {   '1/1/1',   '1/1/2',   '1/1/4',   '1/1/5',     '1/1/7',   '1/1/8',   '1/1/10',   '1/1/11',   '1/1/13',   '1/1/14',   '1/1/16',   '1/1/17',   '1/1/19',   '1/1/20' } for _, address in ipairs(addresses) do   grp.checkwrite(address, on) end



RE: function from timer - admin - 22.07.2026

If you always want to write the timer value then replace these lines (5-7):
Code:
if on then   grp.checkwrite('1/0/1', value) end

With this:
Code:
grp.checkwrite('1/0/1', value)