Page 1 of 1

Naming Conventions in LUA

Posted: Thursday 21 December 2017 9:06
by harrykausl
I'm using lua scripts stored in file system. I have for example several window contacts, they are named "window kitchen", "window bathroom" and so on. What ist the correct naming for lua device scripts for events on this windows. Is it like "script_device_window_kitchen.lua" and I only have the events for this sensor in the script. Or have I to use "script_device_window.lua" and have the events for all windows in it.

Re: Naming Conventions in LUA

Posted: Thursday 21 December 2017 10:15
by jannl
Remember that every time a device is triggered, all device scripts are fired. if you have a lot of devices/scripts, execution time will raise. Especcially the commandarray in every script takes a lot of tiime.

Best way to go is to either create a device containerscript or use dzvents.

Search the forum for more explanation

Re: Naming Conventions in LUA

Posted: Thursday 21 December 2017 10:28
by jvdz
jannl wrote: Thursday 21 December 2017 10:15 Remember that every time a device is triggered, all device scripts are fired. if you have a lot of devices/scripts, execution time will raise. Especcially the commandarray in every script takes a lot of time.
True, but only when there is no script with the devicename these days!
Not sure whether it also does masks in devices names as asked by @harrykausl.
Myself I use one general script for devices and one for time events, which calls the appropriate sub-script in case it involves that particular device or event.

Jos

Re: Naming Conventions in LUA

Posted: Thursday 21 December 2017 10:56
by jannl
ok, didn't know that.
Thanks.

Jan

Re: Naming Conventions in LUA

Posted: Thursday 21 December 2017 11:05
by harrykausl
Thanks, I did some tests and saw, that blanks in device names don't work with device scripts. I think I'll use a container script for all window contacts.

Re: Naming Conventions in LUA

Posted: Saturday 23 December 2017 14:35
by harrykausl
So, now I have 2 container scripts, but I see, that the performance slows down. Is there any solution to make the naming / starting a little bit more comfortable. I need blanks in my devices to make the names understandable. But if I do this, I run all device scripts which are not unique to the device. One solution could be to maks blanks in the script-name. Or use the idx instead of the name.

Re: Naming Conventions in LUA

Posted: Saturday 23 December 2017 15:31
by jvdz
What is the issue with spaces in the Devicenames exactly as I am not aware of any?
Maybe you can post a small example that is giving you an issue?

Jos

Re: Naming Conventions in LUA

Posted: Saturday 23 December 2017 15:37
by harrykausl
Devicename is for example "Window ktichen", "Window sleeping room right", "Window sleeping room left". I don't want to use _ or something else in the names.

Re: Naming Conventions in LUA

Posted: Saturday 23 December 2017 18:37
by jvdz
Understood, but what is the reason you can't use them in LUA?
You stated:
Thanks, I did some tests and saw, that blanks in device names don't work with device scripts.

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 7:33
by dannybloe
I keep saying this: look at dzVents. Takes care of this.

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 8:46
by harrykausl
What I meant is, that when a device is called "Window kitchen" a script_device_Window_kitchen.lua is not automatically startet. I use now a container script for windows where I have all the events for all the windows.

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 10:39
by jvdz
harrykausl wrote: Sunday 24 December 2017 8:46 a script_device_Window_kitchen.lua is not automatically startet.
Change that to script_device_window_kitchen.lua and you should be ok. ;)
dannybloe wrote: Sunday 24 December 2017 7:33 I keep saying this: look at dzVents. Takes care of this.
True, but some of us like to understand and program stuff themselves. 8-)

Jos

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 11:00
by dannybloe
Pick your battles! Why not write C++? Much faster. And gives you even better understanding. :roll:
But it’s up to you indeed if you want to spent time with irrelevant, unnecessary and distracting stuff. :D

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 11:18
by jvdz
dannybloe wrote: Sunday 24 December 2017 11:00 Pick your battles! Why not write C++? Much faster. And gives you even better understanding. :roll:
I know, that is why I write C++ as well to appreciate LUA and all it error handling. :twisted:

Re: Naming Conventions in LUA

Posted: Sunday 24 December 2017 11:19
by jannl
Haha exactly, that's why I do not use dzvents. It is whatJos says.....

What I said before, when you have no programming experience at all, blockly and dzvents are the way to go I think. Otherwise, just use what you like best.

Re: Naming Conventions in LUA

Posted: Wednesday 27 December 2017 11:54
by harrykausl
@jvdz - works, thanks!