Logic Machine Forum
Knx commands in a for loop - 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: Knx commands in a for loop (/showthread.php?tid=4688)



Knx commands in a for loop - Ceros2112 - 29.03.2023

Hello,

I'm trying to make a "reset" function for a series of blind shutters, basically I want to read the actual state, and toggle the command in order to make the shutters move back and forth the actual position.

Everything seems to work fine in the script (I set logs and everything is good) except that shutters don't move  Smile

So I wonder, is it possible to use knx commands in a for loop or there is some kind of limitation?

Thanks for your help.


RE: Knx commands in a for loop - Daniel - 29.03.2023

Share your script first.


RE: Knx commands in a for loop - Ceros2112 - 29.03.2023

Code:
tapp_addresses = {"1/3/4",
                                  "1/3/8",
                                  "1/3/16",
                                  "1/3/19",
                                  "1/3/23",
                                  "1/3/27",
                                  "1/3/35",
                                  "1/3/39",
                                  "1/3/43",
                                  "1/3/47",
                                  "1/3/54",
                                  "1/3/55"
                                  }

grp.write("32/1/15", true)

tapp1 = grp.getvalue("1/3/6")
tapp2 = grp.getvalue("1/3/10")
tapp3 = grp.getvalue("1/3/18")
tapp4 = grp.getvalue("1/3/21")
tapp5 = grp.getvalue("1/3/25")
tapp6 = grp.getvalue("1/3/29")
tapp7 = grp.getvalue("1/3/37")
tapp8 = grp.getvalue("1/3/41")
tapp9 = grp.getvalue("1/3/45")
tapp10 = grp.getvalue("1/3/49")
tapp11 = grp.getvalue("1/3/52")
tapp12 = grp.getvalue("1/3/57")

tapp_array = {tapp1,
                          tapp2,
                          tapp3,
                        tapp4,
                        tapp5,
                        tapp6,
                        tapp7,
                        tapp8,
                        tapp9,
                        tapp10,
                        tapp11,
                        tapp12,}

for i=1,table.getn(tapp_array) do
  if tapp_array[i]>0 then
    log(tapp_array[i])
    log("devo aprire")
    log(tapp_addresses[i])
    grp.write(tapp_addresses[i], true)
    sleep(1)
  else
    log(tapp_array[i])
    log("devo chiudere")
    log(tapp_addresses[i])
    grp.write(tapp_addresses[i], false)
    sleep(1)
  end
end

sleep(5)

tapp1 = grp.getvalue("1/3/6")
tapp2 = grp.getvalue("1/3/10")
tapp3 = grp.getvalue("1/3/18")
tapp4 = grp.getvalue("1/3/21")
tapp5 = grp.getvalue("1/3/25")
tapp6 = grp.getvalue("1/3/29")
tapp7 = grp.getvalue("1/3/37")
tapp8 = grp.getvalue("1/3/41")
tapp9 = grp.getvalue("1/3/45")
tapp10 = grp.getvalue("1/3/49")
tapp11 = grp.getvalue("1/3/52")
tapp12 = grp.getvalue("1/3/57")

tapp_array = {tapp1,
                          tapp2,
                          tapp3,
                        tapp4,
                        tapp5,
                        tapp6,
                        tapp7,
                        tapp8,
                        tapp9,
                        tapp10,
                        tapp11,
                        tapp12,}

for i=1,table.getn(tapp_array) do
  if tapp_array[i]>0 then
    log(tapp_array[i])
    log("devo aprire")
    log(tapp_addresses[i])
    grp.write(tapp_addresses[i], true)
    sleep(7)
  else
    log(tapp_array[i])
    log("devo chiudere")
    log(tapp_addresses[i])
    grp.write(tapp_addresses[i], false)
    sleep(7)
  end
end

grp.write("32/1/15", false)



RE: Knx commands in a for loop - admin - 29.03.2023

What is the datatype for status objects (1/3/6, 1/3/10 etc)?


RE: Knx commands in a for loop - Ceros2112 - 29.03.2023

For tapp_addresses array 1.008
For tapp_array elements 5.001


RE: Knx commands in a for loop - admin - 29.03.2023

Do you see control objects (1/3/4, 1/3/8 etc) change in the UI when the script executes?


RE: Knx commands in a for loop - Ceros2112 - 29.03.2023

I can't try it right now but last time I checked yes, I will run some tests later.

By the way, the whole system is up and running with a custom visualization in which the same addresses are controlled with buttons and everything works fine.

I ran a test using an array that contains only one "dummy"group address and it works, I wil run the real test later but I expect that everything will work...otherwise I have no idea