Page 1 of 1
Is better to put lua script in the domoticz "events" or in the folder "script/lua"?
Posted: Thursday 06 April 2017 10:04
by bigpea
Hi all,
I'd like to know if is better to put the LUA script in the domoticz "events" or in the fonder "domoticz/script/lua" as file (script_device_demo.lua).
I'd like to know if is better regarding the performance, it's faster? It's more reliable?
Thanks.
Re: Is better to put lua script in the domoticz "events" or in the folder "script/lua"?
Posted: Thursday 06 April 2017 12:08
by Nautilus
In file system it is a bit faster. Shouldn't be any difference with reliability. Using the file system also allows you to create a master script ("container") for device changes so that the system needs to run only one script (saves a lot of CPU) when there is a device change. See the forum for more examples...
You can also look into dzVents which is kind of a framework to easily achiever the master script approach:
https://www.domoticz.com/forum/viewforum.php?f=59 - or if you are into php search for "pass2php" (
https://www.domoticz.com/forum/viewtopi ... 64&t=12343)
Re: Is better to put lua script in the domoticz "events" or in the folder "script/lua"?
Posted: Thursday 06 April 2017 12:13
by bigpea
Ok many thanks.
I will see to follow your suggestion.
Thanks.
Re: Is better to put lua script in the domoticz "events" or in the folder "script/lua"?
Posted: Thursday 06 April 2017 12:25
by emme
not only...
by my understanding the event system fires scripts as the events is triggered regadless of the state of the actual running script.
This means that if a device event is triggered, a script will run... if in the meantime another device is triggered, the same script is fired again, so you do have 2 session of the same script that is running
this COULD be a bit messy: tables are generated and available at the beginning of the script and commands are executed at the end of the script (when the return commandArray is computed) so the device table can be outdated by the first script while the second is still running.
An evidence of this behaviour could be a double notification (if you do have any)
In File system method, scripts are not fired twice... the system waits until the previous session has finished
(I'm unclear if this could mean I could miss some events or not

)
ciao
M
P.S.
I personally use the web ide to create and test scripts... than I move them to files
(since there is not a good IDE under ssh for domoticz/luz scripts

:P)
Re: Is better to put lua script in the domoticz "events" or in the folder "script/lua"?
Posted: Thursday 06 April 2017 12:55
by bigpea
Yes emme, I agree with you.
The best way is to use the Web Interface to develope the script and after the test to put the script in the file system.
But regarding the dzVents, it seems very nice, I will study it.