Naming Conventions in LUA

Moderator: leecollings

Post Reply
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Naming Conventions in LUA

Post 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.
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Naming Conventions in LUA

Post 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
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Naming Conventions in LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Naming Conventions in LUA

Post by jannl »

ok, didn't know that.
Thanks.

Jan
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Naming Conventions in LUA

Post 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.
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Naming Conventions in LUA

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Naming Conventions in LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Naming Conventions in LUA

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Naming Conventions in LUA

Post 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.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Naming Conventions in LUA

Post by dannybloe »

I keep saying this: look at dzVents. Takes care of this.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Naming Conventions in LUA

Post 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.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Naming Conventions in LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Naming Conventions in LUA

Post 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
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Naming Conventions in LUA

Post 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:
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Naming Conventions in LUA

Post 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.
harrykausl
Posts: 184
Joined: Sunday 13 November 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Naming Conventions in LUA

Post by harrykausl »

@jvdz - works, thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest