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.

Support Request on Lua Scripting
#4
(13.08.2021, 09:21)admin Wrote: This can be optimized further by checking if the device as sent a telegram to a specific group address in the last X minutes. If it did then there's no point in checking the physical address. It's also advisable to add a small delay between each check so the bus is not overloaded.

For table iteration you can use ipairs, then the count loop is not needed (you can also use #addresses to get the table length).
Code:
for _, address in ipairs(addresses) do
  result = knxlib.ping(address)
  if result == false then
    content2 = content2 .. 'Address: ' .. address .. ' - <b>ERROR!</b><br>'
  end
end

See a similar example for the second function: https://forum.logicmachine.net/showthread.php?tid=1967

Thank you all for the support.

I have added all devices on the table and added a delay for the ping function. Mail also works well.

Code:
addresses = {
'1.1.1',
'1.1.2',
'1.1.3',
'1.1.4',
'1.1.5',
'1.1.6',
'1.1.7',
'1.1.8',
'1.1.9',
'1.1.10',
'1.1.11',
'1.1.12',
'1.1.13',
'1.1.14',
'1.1.15',
'1.1.16',
'1.1.17',
'1.1.18',
'1.1.19',
'1.1.20',
'1.1.21',
'1.1.22',
'1.1.23',
'1.1.24',
'1.1.25',
'1.1.26',
'1.1.27',
'1.1.28',
'1.1.29',
'1.1.30',
'1.1.31',
'1.1.32',
'1.1.33',
'1.1.34',
'1.1.35',
'1.1.36',
'1.1.37',
'1.1.38',
'1.1.39',
'1.1.40',
'1.1.41',
'1.1.42',
'1.1.43',
'1.1.44',
'1.2.1',
'1.2.2',
'1.2.3',
'1.2.4',
'1.2.5',
'1.2.6',
'1.2.7',
'1.2.8',
'1.2.9',
'1.2.10',
'1.2.11',
'1.2.13',
'1.2.14',
'1.2.15',
'1.2.16',
'1.2.17',
'1.2.18',
'1.2.19',
'1.2.20',
'1.2.21',
'1.2.22',
'1.2.23',
'1.2.24',
'1.2.25',
'1.2.26',
'1.2.27',
'1.2.28',
'1.2.29',
'1.2.30',
'1.2.31',
'1.2.32',
'1.2.33',
'1.2.34',
'1.2.35',
'1.2.36',
'1.2.37',
'1.2.38',
'1.2.39',
'1.2.40',
'1.2.41',
'1.2.42',
'1.2.43',
'1.2.44',
'1.2.45',
'1.2.46',
'1.2.47',
'1.2.48',
'1.2.49',
'1.2.50',
'1.2.51',
'1.2.52',
'1.2.53',
'1.2.54',
'1.2.55',
'1.2.56',
'1.3.1',
'1.3.2',
'1.3.3',
'1.3.4',
'1.3.5',
'1.3.6',
'1.3.7',
'1.3.8',
'1.3.9',
'1.3.10',
'1.3.11',
'1.3.12',
'1.3.13',
'1.3.14',
'1.3.15',
'1.3.16',
'1.3.17',
'1.3.18',
'1.3.19',
'1.3.20',
'1.3.21',
'1.3.22',
'1.3.23',
'1.3.24',
'1.3.25',
'1.3.26',
'1.3.27',
'1.3.28',
'1.3.29',
'1.3.30',
'1.3.31',
'1.3.32',
'1.3.33',
'1.3.34',
'1.3.35',
'1.3.36',
'1.3.37',
'1.3.38',
'1.3.39',
'1.3.40',
'1.3.41',
'1.3.42',
'1.3.43',
'1.3.44',
'1.3.45',
'1.3.46',
'1.3.47',
'1.3.48',
'1.3.49',
'1.3.50',
'1.3.51',
'1.3.52',
'1.3.53',
'1.3.54',
'1.3.55',
'1.3.56',
'1.3.57',
'1.3.58',
'1.4.1',
'1.4.2',
'1.4.3',
'1.4.4',
'1.4.5',
'1.4.6',
'1.4.7',
'1.4.8',
'1.4.9',
'1.4.10',
'1.4.11',
'1.4.12',
'1.4.13',
'1.4.14',
'1.4.15',
'1.4.16',
'1.4.17'
}

--Address Count
ie=1
while (addresses[ie]~=nil) do
  ie=ie+1
end

--ping addresses
content='<b>KNX Physical Address Check</b><br><br>'
content2=''

for _, address in ipairs(addresses) do
  result = knxlib.ping(address)
  os.sleep(0.5)
  if result == false then
    content2 = content2 .. 'Motion Detector - Address: ' .. address .. ' - <b>IS OFFLINE!</b><br>'
  end
end

--send email
if content2 ~= '' then
  res, err =   mail('123456@gmail.com', 'KNX Installation Fault',content2)
end


After the mail function I would like to reset the motion detection telegram of the device(s) that is offline. I was thinking to tag the group address with the phys address and then have a function in this scipt to write to the result a false.

How can i do this?

Or can I add an array of data to include the address and next to it the coresponding motion detection GA?

something like this

{ address = '1.1.1', motion = '2/1/1' },

{ address = '1.1.2', motion = '2/1/2' }


In this case how would the script look like?
Reply


Messages In This Thread
RE: Support Request on Lua Scripting - by manos@dynamitec - 13.08.2021, 18:48

Forum Jump: