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.

function from timer
#1
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
Reply
#2
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
Reply
#3
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
Reply
#4
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)
Reply


Forum Jump: