Logic Machine Forum
array of group addresses - Printable Version

+- Logic Machine 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: array of group addresses (/showthread.php?tid=5518)



array of group addresses - almoisey - 18.07.2024

Hello. I have a task to write an array of identical values to a large number of group addresses (~200) ( like grp.write('1/*/*', value)). How can this be done using array commands?
Thanks


RE: array of group addresses - admin - 18.07.2024

Assign a common tag to the required objects then use this script:
Code:
value = 1
objects = grp.tag('my_tag_name')

for _, obj in ipairs(objects) do
  res = obj:checkwrite(value)
  if res then
    os.sleep(0.1)
  end
end

A better approach is to assign a common group address to all KNX devices because sending many telegrams at once can overflow the bus. The script above has a delay between each telegram to prevent this but it means that some devices will receive the value later.