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.

Knx commands in a for loop
#1
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.
Reply
#2
Share your script first.
------------------------------
Ctrl+F5
Reply
#3
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)
Reply
#4
What is the datatype for status objects (1/3/6, 1/3/10 etc)?
Reply
#5
For tapp_addresses array 1.008
For tapp_array elements 5.001
Reply
#6
Do you see control objects (1/3/4, 1/3/8 etc) change in the UI when the script executes?
Reply
#7
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
Reply


Forum Jump: