Maximum of lua scripts?
Moderator: leecollings
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Maximum of lua scripts?
Raspberrypi 3,
latest stable release of Domoticz
I have 14 devices scripts, 6 time scripts and 3pcs of variable scripts and one of devices scripts work calculation with 10 devices (each 5seconds) .. and I'm getting delay in reactions of other lua scripts.
Is it any maximum of lua scripts?
Is it better write scripts in some other languages ? (because of performance)
Maybe python scripts running out of domoticz core and have better performance ??
thanks for help.
latest stable release of Domoticz
I have 14 devices scripts, 6 time scripts and 3pcs of variable scripts and one of devices scripts work calculation with 10 devices (each 5seconds) .. and I'm getting delay in reactions of other lua scripts.
Is it any maximum of lua scripts?
Is it better write scripts in some other languages ? (because of performance)
Maybe python scripts running out of domoticz core and have better performance ??
thanks for help.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
The Lua language interpreter by itself is very close to C and switching to another (script) language will not improve performance as such.
The way classic Lua scripts are implemented in domoticz might cause your issue.
Every device script is executed on every device update in the system and every time script is executed every minute and every variable script is executed every variable update, etc.
Every script trigger will receive a copy of the domoticz object with many sub-tables.
This is the reason why @Dannybloe and @jvandenbroek designed and integrated dzVents in domoticz. In dzVents only 1 Lua script is triggered for these events (device, time, variable, etc) and that single Lua scripts only loads the user scripts when needed.
This improves response times significantly, especially when the number of scripts rises.
You might want to have a look at the dzVents wiki
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
I have onchange condition in each script.
When I last time enabled dzVents, Domoticz freezes few times in hour
I will try it again.
Thanks for now.
When I last time enabled dzVents, Domoticz freezes few times in hour

I will try it again.
Thanks for now.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
That will not prevent the script from being triggered.
In my experience the script itself is hardly ever causing a response issue if you don't use blocking commands like os.execute or io.popen.
For these type of commands dzVents have async alternatives.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
Yes,
maybe this is problem.. I have os.execute in one script.. I will move this one to the dzVents.
maybe this is problem.. I have os.execute in one script.. I will move this one to the dzVents.
-
- Posts: 673
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: Maximum of lua scripts?
Propably all the commandArray commands are causing the delay.
Do as suggested above, use dzVents, or create your own containerscript like I did, partly because dzVents did not exist at the time and partly because I better like the straight forward programming.
Jan
Do as suggested above, use dzVents, or create your own containerscript like I did, partly because dzVents did not exist at the time and partly because I better like the straight forward programming.
Jan
-
- Posts: 748
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Maximum of lua scripts?
I have a script that runs for about 30 seconds, and I fully understand why (this is OK, not an error).
In LUA it throws a warning that the script runs for more than 10 seconds.
So I decided to move the function to a dzVents script, hoping to lose the error. Not so, it gives me the same error message...
Is there a way around this, or should I learn to live with it?
In LUA it throws a warning that the script runs for more than 10 seconds.
So I decided to move the function to a dzVents script, hoping to lose the error. Not so, it gives me the same error message...
Is there a way around this, or should I learn to live with it?
Hans
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
Best to share the script. That might help in understand why the 30 seconds are needed and to advise a possible work around (if any)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- jvdz
- Posts: 2330
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
Well, it isn't really OK as you are "hanging" the whole event system due to it being single threaded.
One should really run these script in an async way by either shelling it with os.execute("command &") or running it by crontab, but it can't obviously not have an commandArray returning any updates, so those would have to be done with JSON calls in the script.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
Or even better use dzVents async executeShellCommand() in combination with shellCommandResponses (available in domoticz >= build 12771)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
build 12771 ... I must update to latest beta.. aaand when I last time tried it.. lot of energy devices doesn't have any value and part of house not worked anymore

When I see issue list in latest beta.. it's little bit risky.. or not ??
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
Risk can be mitigated by ensuring you have a recent and tested backup of your domoticz directory and subdirectory's (exclude the backups subdirectory)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
Update looks good but I have this in log and I'm trying to search at forum but without success..
2021-03-31 21:17:40.579 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.out
2021-03-31 21:17:40.580 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.err
2021-03-31 21:19:28.442 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1062.out
2021-03-31 21:19:28.442 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1062.err
2021-03-31 21:23:40.904 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1163.out
2021-03-31 21:23:40.904 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1163.err
2021-03-31 21:24:17.896 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1177.out
2021-03-31 21:24:17.896 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1177.err
2021-03-31 21:28:18.573 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1274.out
2021-03-31 21:28:18.573 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1274.err
2021-03-31 21:30:13.902 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1321.out
2021-03-31 21:30:13.902 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1321.err
2021-03-31 21:32:11.882 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1368.out
2021-03-31 21:32:11.882 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1368.err
2021-03-31 21:17:40.579 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.out
2021-03-31 21:17:40.580 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.err
2021-03-31 21:19:28.442 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1062.out
2021-03-31 21:19:28.442 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1062.err
2021-03-31 21:23:40.904 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1163.out
2021-03-31 21:23:40.904 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1163.err
2021-03-31 21:24:17.896 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1177.out
2021-03-31 21:24:17.896 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1177.err
2021-03-31 21:28:18.573 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1274.out
2021-03-31 21:28:18.573 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1274.err
2021-03-31 21:30:13.902 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1321.out
2021-03-31 21:30:13.902 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1321.err
2021-03-31 21:32:11.882 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1368.out
2021-03-31 21:32:11.882 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1368.err
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
Seems to be an authorisation issue. These files should not be in /home/pi/domoticz/scripts/dzVents/data/ and can be removed from the command line usingJohnnySK wrote: ↑Wednesday 31 March 2021 21:36 Update looks good but I have this in log and I'm trying to search at forum but without success..
2021-03-31 21:17:40.579 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.out
2021-03-31 21:17:40.580 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1017.err
...
2021-03-31 21:32:11.882 Error: unable to remove file /home/pi/domoticz/scripts/dzVents/data/domscript1368.err
Code: Select all
sudo rm /home/pi/domoticz/scripts/dzVents/data/*.out /home/pi/domoticz/scripts/dzVents/data/*.err
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
I tried change permissions on whole folder.
Files create domoticz and removing them too.. They are connected to my first dzVents skript where I'm using domoticz.executeShellCommand().
But I don't know why domoticz wont again remove already removed files.
Files create domoticz and removing them too.. They are connected to my first dzVents skript where I'm using domoticz.executeShellCommand().
But I don't know why domoticz wont again remove already removed files.
-
- Posts: 748
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Maximum of lua scripts?
Script is very simple. It starts a speedtest to measure line speeds.
Code: Select all
return {
on = {
devices = {
'Utrecht speedtest trigger'
}
},
execute = function(domoticz, device)
if (device.state =='On') then
print ("speedtest_device_dzvents starting speedtest measurement")
os.execute ("sudo bash /home/pi/domoticz/scripts/speedtest2.sh")
end
end
}
I tried to use this:
Code: Select all
domoticz.executeShellCommand('/home/pi/domoticz/scripts/speedtest2.sh')
Code: Select all
2021-03-31 22:28:41.852 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Speedtest_device
2021-03-31 22:28:41.852 Error: dzVents: Error: (3.0.2) ...z/scripts/dzVents/generated_scripts/Speedtest_device.lua:11: attempt to call a nil value (field 'executeShellCommand')
Last edited by manjh on Wednesday 31 March 2021 22:30, edited 2 times in total.
Hans
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
I have it similar
scripts have --silent parameter in each call.. so doesn't have output.. but files appear and disappear in data folder and errors still comming
Code: Select all
return {
on = {
devices = {
'Batt Napatie'
}
},
execute = function(domoticz, device)
domoticz.executeShellCommand('/home/pi/domoticz/scripts/pv_fpv1.sh &')
domoticz.executeShellCommand('/home/pi/domoticz/scripts/pv_fpv2.sh &')
end
}
- JohnnySK
- Posts: 25
- Joined: Thursday 28 May 2015 22:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Slovakia
- Contact:
Re: Maximum of lua scripts?
Update domticz.. dzVents have executeShellCommand from 12771 buildI tried to use this:but am getting an error:Code: Select all
domoticz.executeShellCommand('/home/pi/domoticz/scripts/speedtest2.sh')
Code: Select all
2021-03-31 22:28:41.852 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Speedtest_device 2021-03-31 22:28:41.852 Error: dzVents: Error: (3.0.2) ...z/scripts/dzVents/generated_scripts/Speedtest_device.lua:11: attempt to call a nil value (field 'executeShellCommand')
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
You should not use the background operator (&) with domoticz.executeShellCommand()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Maximum of lua scripts?
when using os.execute you should use the background operator
Code: Select all
os.execute('/home/pi/domoticz/scripts/speedtest2.sh &')
domoticz.executeShellCommand is available in dzVents >= 3.1I tried to use this:but am getting an error:Code: Select all
domoticz.executeShellCommand('/home/pi/domoticz/scripts/speedtest2.sh')
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest