Logic Machine Forum
Read many KNX group adresses in one go. - 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: Read many KNX group adresses in one go. (/showthread.php?tid=626)



Read many KNX group adresses in one go. - Trond Hoyem - 17.02.2017

Hi

I would like to have a script that checks the values of several group adresses in KNX at a certain time of day.

How can I set this up in an easy way? I understand I can just do grp.read(), but how can I do this to more than one GA's without having to type in a lot of lines.

BR
Trond


RE: Read many KNX group adresses in one go. - gjniewenhuijse - 17.02.2017

Tag every object you want to read, for example: read_chk1
In scheduler script loop in your tags like:

myobjects = grp.tag('read_chk1')
for index, value in ipairs(myobjects) do
 -- here your code
end


RE: Read many KNX group adresses in one go. - Trond Hoyem - 17.02.2017

Hm...
Did not work. I entered the following:

----------------------------------------------------------
myobjects = grp.tag('Status_value')

for index, value in ipairs(myobjects) do
grp.read(myobjects)


end

grp.read('0/0/3')
-----------------------------------------------

The last grp.read() is just for me to see that the script is running...

I did not get any read requests on the group adresses tagged with 'Status_value'. Maybe the grp.read() is not the correct command to use in my case?

I am rather new to this scripting things, so please bear with me :-)


RE: Read many KNX group adresses in one go. - admin - 17.02.2017

Also, keep in mind that read sends a KNX read telegram and does not return object value. If you want to get current object value then you should use grp.getvalue instead.


RE: Read many KNX group adresses in one go. - admin - 17.02.2017

Use this for tags:
Code:
myobjects = grp.tag('Status_value')
myobjects:read()



RE: Read many KNX group adresses in one go. - Erwin van der Zwart - 17.02.2017

Hi,

myobjects is a table that is read line by line, each line is now set to value and is (in this case) also a table, value.address is the field you need..

use: grp.read(value.address)

BR,

Erwin


RE: Read many KNX group adresses in one go. - Trond Hoyem - 17.02.2017

...so simple...

Worked perfectly! Thanks!