Hallo,
I need create a OR port with about 90-100 input. I tagged each input in objects window. It's possible create the OR gate useing the tag of the group address?
I wrote the follow example that don't function:
if (true == grp.tag('LuciScalaA')) then
grp.write('12/1/21', true)
else
os.sleep(100)
grp.write('12/1/21', false)
end
21.01.2019, 21:51 (This post was last modified: 21.01.2019, 21:54 by Erwin van der Zwart.)
Hi,
grp.tag will always return a table with objects so this is never true or false..
Here are the needed scripts for logical and/or by TAG:
Code:
-- Logical OR port by tagged objects
tagname = 'OR_LOGIC'
output = '1/1/1'
for i, object in ipairs(grp.tag(tagname)) do
if object.data then
grp.checkwrite(output, true, 1)
return
end
end
grp.checkwrite(output, false, 1)
Code:
-- Logical AND port by tagged objects
tagname = 'AND_LOGIC'
output = '1/1/1'
for i, object in ipairs(grp.tag(tagname)) do
if not object.data then
grp.checkwrite(output, false, 1)
return
end
end
grp.checkwrite(output, true, 1)
if(value or value2 or value3 == true) then
grp.write(output, true)
else
grp.write(output, false)
end
Or this one:
Quote:tagname = 'OR_LOGIC'
output = 'output_address'
for i, object in ipairs(grp.tag(tagname)) do
if object.data then
grp.checkwrite(output, true, 1)
return
end
end
grp.checkwrite(output, false, 1)
I have many lights and many rooms and if I turn on ALL lights at the same time there are a lot of scripts executing at once, so I need the most perfomance-effective solution.
Well you see I have a problem with this one. As I have A LOT lights, it feels that if many lights are turning on/off the script starts to "hang" and doesn't update any addresses any more and then it needs to be disabled/enabled to work again. I've tried upgrading LM to newest version but it didn't help so I'm kind of stuck with those 2 scripts.
If you have a lot of lights then this script is much better as it is just one PID, The other creates a lots of them with each telegram sent. Can you send me your project to PM to check why it is happening, It could be some bug or other reason.