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.

Stop execution of KNX secuence
#1
Hello from Spain,

i have a script with a secuence in KNX, using "os.sleep(t)" to do a delay between telegrams. It works well, but in any case, the secuence duration is 4-5 minutes.
¿How can i do to stop the secuence in the middle of execution? Any "break" or "exit" or "kill" exception to stop the script.


Code:
os.sleep(23)
  grp.write('0/0/39', 0)
  grp.write('0/0/53', 0)
  grp.write('0/0/56', 0)
  grp.write('0/0/58', 0)
  grp.write('0/0/40', 0)
  grp.write('0/0/62', 0)
  grp.write('0/0/47', 0)
  grp.write('0/0/41', 1)
  grp.write('0/0/7', 1)
  grp.write('0/5/8', 100)
  grp.write('0/0/29', 1)
  grp.write('0/0/33', 1)
  os.sleep(14)
  grp.write('0/0/41', 0)
  grp.write('0/0/7', 0)
  grp.write('0/0/29', 0)
  grp.write('0/0/33', 0)
  grp.write('0/0/38', 1)
  grp.write('0/0/59', 1)
  grp.write('0/0/60', 1)
  grp.write('0/0/61', 1)
  os.sleep(39)
  grp.write('0/5/8', 0)
  grp.write('0/0/38', 0)
  grp.write('0/0/59', 0)
  grp.write('0/0/60', 0)
  grp.write('0/0/61', 0)
  grp.write('0/0/29', 1)


Thanks!

Iván.
Reply
#2
You can use an object or a storage variable as a status, then check this status after each sleep:
Code:
os.sleep(23)
if not grp.getvalue('1/1/1') then
  return
end
Reply
#3
(31.08.2017, 11:29)admin Wrote: You can use an object or a storage variable as a status, then check this status after each sleep:
Code:
os.sleep(23)
if not grp.getvalue('1/1/1') then
 return
end

Thanks admin!!

It works! The inconvenience is that i have to copy that a lot of times in the code, but it works.

Ivan.
Reply
#4
You can prepare some table with values and then iterate over it with some loop.This is only a little inspirationWink

Code:
pause = 14 -- seconds
statusGA = '1/1/1'

sequence = {
{grp = '1/2/3', val = 1 },
{grp = '1/2/6', val = 100 }
}

for _, scene in ipairs(sequence) do
grp.write(scene.grp, scene.val)
if grp.getvalue(statusGA) == false then break end
os.sleep(pause)
end
Reply
#5
Hi Buuuudzik,

Check your sample (:

statusGA is a address (string) and not a value so will never be false (bool)

BR,

Erwin
Reply
#6
Thanks, yes I've updated the above scriptWink
Reply


Forum Jump: