![]() |
|
scripting knx - Printable Version +- LogicMachine 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: scripting knx (/showthread.php?tid=6381) Pages:
1
2
|
scripting knx - ALEJANDRO - 08.04.2026 Good morning, I'm having a problem with the functions and I don't know how to solve it. Here's the problem: I currently have three logic machines taking KNX data from temperature, humidity, and CO2 sensors. I need them to calculate the average temperature, CO2, and humidity. But I only want to calculate this for the sensors located in rented properties. I have the following variables. Rented or non-rented status of 27 dwellings in group addresses from 2/0/176 to 2/0/202: - Rented = 1 - Non-rented = 0 Temperature values delivered by each dwelling sensor: '0/0/11','0/0/27','0/0/43','0/0/59','0/0/75','0/0/91','0/0/107', '0/0/123','0/0/139','0/0/155','0/0/171','0/0/187','0/0/203', '0/0/219','0/0/235','0/0/251', '0/1/11','0/1/27','0/1/43','0/1/59','0/1/75','0/1/91','0/1/107', '0/1/123','0/1/139','0/1/155','0/1/171' Variable where the average building temperature will be stored: 2/0/164 And now I'll show you the code I wrote: Code: -- Direcciones de estado de las 27 viviendas (0=libre, 1=alquilada, 2=mantenimiento, 3=ocupada)Lo he intentado por todos los medios posibles y no me calcula la temperatura media y cuando lo hace satura la memoria de la logic machine. RE: scripting knx - admin - 08.04.2026 What script type are you using? The correct approach is to use a scheduled script that runs every 5 minutes and remove the while loop and os.sleep at the end. What is the data type of rented status object. Is it boolean or 1 byte? RE: scripting knx - ALEJANDRO - 08.04.2026 Buenas tardes, Estaba ocupado con la construcción. Adjunto fotos del tipo de datos utilizado para los estados de las propiedades; es la versión 7.2. En cuanto al script, se trata de un script basado en eventos. RE: scripting knx - admin - 08.04.2026 It can't be an event script. Make a scheduled script as suggested earlier. RE: scripting knx - ALEJANDRO - 08.04.2026 I haven't tried yet to create scripts scheduled at specific times and dates; I'm worried that the code won't understand that it needs to update the average temperature every 5 or 10 minutes. RE: scripting knx - AEK - 09.04.2026 (08.04.2026, 14:59)ALEJANDRO Wrote: I haven't tried yet to create scripts scheduled at specific times and dates; I'm worried that the code won't understand that it needs to update the average temperature every 5 or 10 minutes. If you need to start script every 5 minutes then you can set '*/5' in minutes parameter RE: scripting knx - ALEJANDRO - 09.04.2026 Are you sure this is 5 minutes? RE: scripting knx - admin - 09.04.2026 Yes, it is. But you need to remove the while loop from the code for it to works correctly. Check the Logs tabs, you will see 5 minutes between logs from this script. Code: local estados = {}RE: scripting knx - ALEJANDRO - 10.04.2026 Yes, of course I realized about that, thanks RE: scripting knx - ALEJANDRO - 13.04.2026 Is it possible to create a resident script whose execution frequency is the value in hours of a group address called frequency_Test_Comms? RE: scripting knx - Daniel - 13.04.2026 Can you explain what task are you trying to solve? Most likely there is simpler solution. RE: scripting knx - ALEJANDRO - 13.04.2026 Let me explain. I have a series of IP addresses that I need to check: - Portal 1 IP: 192.168.0.11 on 32/3/14 - Portal 2 IP: 192.168.0.12 on 32/3/15 - Portal 3 IP: 192.168.0.13 on 32/3/16 - Garage IP: 192.168.0.16 on 32/3/17 If a ping is successful and there is communication, the idea is to set IP addresses 32/3/14, 15, 16, and 17 to 1. If there is no communication after the ping, the idea is to trigger alarms stored on the following addresses by setting these addresses to 1: - Portal 1_Alarm IP on 32/3/27 - Portal 2_Alarm IP on 32/3/28 -ip portal 3_Alarma on 32/3/29 -ip Garaje_Alarma on 32/3/30 This IP monitoring process depends on two variables: frec_test_comms 32/3/40 = 1 Enable_Test_IP 32/3/41 = 1 RE: scripting knx - Daniel - 13.04.2026 Well you can make os.delay(3600) 3600=1h but why do you want to make it configurable? RE: scripting knx - ALEJANDRO - 13.04.2026 I'm being asked to do this in the project, I'll try to explain. The project tells me that the LMs (4 in total) and the gateways connected to each logic machine should have their IPs monitored based on whether an enabler variable, enable_test_ip = 1 and frec_test_comms = 1. enable_test_ip is boolean, frec_test_comms can be in a range from 1 hour to 23 hours. RE: scripting knx - admin - 14.04.2026 Create a scheduled script that runs once every hour. Use the following settings: Minute: 0 Hour: * Day of the month: * Month of the year: Every month of the year Day of the week: Every day of the week Add your test sequence to the end of this script: Code: test_enabled = grp.getvalue('32/3/41')RE: scripting knx - ALEJANDRO - 17.04.2026 Okay, I copied and pasted the script. But it's not running every hour. I know the function works: Code: test_enabled = grp.getvalue('32/3/41')I think everything is correct, thanks. RE: scripting knx - admin - 17.04.2026 Check LM Error log. Why do you need two group addresses for status? RE: scripting knx - ALEJANDRO - 21.04.2026 It's a condition imposed by the engineering firm that hired my company. In any case, don't worry, the function is finally working; it does what it's supposed to do. RE: scripting knx - ALEJANDRO - 04.05.2026 Good morning, a month ago you helped me with a script programmed to run according to the hourly value of a group address. I wanted to ask if, if we want a script to run according to a variable that has a value between 10 and 55 minutes (6/1/1), the following code and the image configuration would be correct. For example, if 6/1/1 were to have a value of 30 minutes, would this configuration cause the script to run only every 30 minutes? RE: scripting knx - admin - 04.05.2026 You need to use a different storage key for each script with a similar logic. You have configured the script to run every 10 minutes so you cannot specify exact running time like 17 or 23 minutes. |