Support Request on Lua Scripting - 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: Support Request on Lua Scripting (/showthread.php?tid=3510) |
Support Request on Lua Scripting - manos@dynamitec - 12.08.2021 Hello everyone, I have an upcoming project which I would like your support regarding the Lua Scripting. A LM5 Lite will be used for this connected on the KNX TP Main Line. The functions I need to implement are described below: Function 1 : 175 KNX Detectors must be monitored if are online on the KNX bus - KNX Watchdog script running every hour. If one or more devices are offline then: Step 1: Send email with a certain subject and body including the phys. address of the device(s) being offline. Step 2: Check (tagged objects) and reset if necessary the corresponding motion detection objet to 'false', of the device(s) being offline. Function 2: Calculate (OR Logic) if there is motion in the building; for this I have the nice resident script from the forum. This will send a bit object as a result where then I will have event script for: Step 1: If not motion then grp.write('xx/xx/xx', true) else (reset timer from step 3) end Step 2: Store a timestamp of the event Step 3: Resident Script every 1sec to compare this timestamp with the actual time of the LM. If delta (t) > 900 (sec) then grp.checkwrite('xx/xx/xx, true) else grp.checkwrite('xx/xx/xx', false). Thank you in advance for the support and always being helpful and active. Kind regards RE: Support Request on Lua Scripting - fleeceable - 12.08.2021 There is probably some better ways but I did something like this (Function 1): Code: addresses = { Probably I would use Dynamic Folder in ETS to get all needed devices with physical addresses and save/print it to pdf. Copy all PA-s to notepad++ and use replace function to modify PA-s (like they are in script on line 2 to 13) that you can copy all addresses to script at once. It's about 10 min job to get all 175 addresses into script. I hope this helps... RE: Support Request on Lua Scripting - admin - 13.08.2021 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 See a similar example for the second function: https://forum.logicmachine.net/showthread.php?tid=1967 RE: Support Request on Lua Scripting - manos@dynamitec - 13.08.2021 (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. 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 = { 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? RE: Support Request on Lua Scripting - admin - 16.08.2021 Use this: Code: devices = { RE: Support Request on Lua Scripting - manos@dynamitec - 17.08.2021 (16.08.2021, 07:39)admin Wrote: Use this: Thank you admin. Great support as always. RE: Support Request on Lua Scripting - manos@dynamitec - 21.02.2022 Hello Admin, I have noticed that in same casses the watchdog is very sensitive. I believe if the moment of the knx device ping there is high bus load the LM will not get a reply and think a device is offline. How many times is the ping sent to the bus? Could we set a three times repeat in case there is no reply from a device before considering it as offline? or a delay for the reply maybe? An other thing I would like to have is if possible to include a date/time stamp before or after the offline device. Something to indicate the date time this error occured. The date and time from the email could be used also as an indicator but it would be nice to have in the content of it also. If this script is ment to run every hour, is there a way to accumulate the errors if any and then send them only once per day by mail? Thank you again for the support. RE: Support Request on Lua Scripting - admin - 21.02.2022 You can send ping several times like this. You can also increase the sleep time between each device check from 0.5 to a higher value if needed. Code: for i = 1, 3 do You can get current date/time by calling os.date(). You can use this example to store events into a storage log: https://forum.logicmachine.net/showthread.php?tid=350 A separate scheduled script can send event log data to email once per day. RE: Support Request on Lua Scripting - nmedalacabeza - 29.12.2022 Hello, how to ping a device? I can't get him to answer what's wrong with me? Code: result = knxlib.ping('32/3/40') --- cadena 250 bytes??? RE: Support Request on Lua Scripting - Daniel - 30.12.2022 The ping parameter should be a physical address of a device you want to ping not a group address. Like this result = knxlib.ping('1.1.1') RE: Support Request on Lua Scripting - nmedalacabeza - 30.12.2022 (30.12.2022, 10:03)Daniel Wrote: The ping parameter should be a physical address of a device you want to ping not a group address. Like thisHow do I transfer it to the screen if it is not with a group address? to be able to ping one device or another. Thank you RE: Support Request on Lua Scripting - Erwin van der Zwart - 31.12.2022 You could use a string object, but i would use 3 byte objects 1.2.3 and fetch the entered values with script to avoid invalid user input. Limit the input values to the KNX standard on the start and middle object value in the object parameters. Code: start = grp.getvalue('1/1/1') RE: Support Request on Lua Scripting - nmedalacabeza - 31.12.2022 (31.12.2022, 08:21)Erwin van der Zwart Wrote: You could use a string object, but i would use 3 byte objects 1.2.3 and fetch the entered values with script to avoid invalid user input. to confirm the reading would be like this? Thank you Code: start = grp.getvalue('32/3/43') RE: Support Request on Lua Scripting - Erwin van der Zwart - 01.01.2023 No, dev is the device physical address x.x.x and not the result of the ping itself.. Code: res = knxlib.ping(dev) RE: Support Request on Lua Scripting - nmedalacabeza - 01.01.2023 (01.01.2023, 09:47)Erwin van der Zwart Wrote: No, dev es la dirección física del dispositivo xxx y no el resultado del ping en sí. ok , thank you |