Naming Conventions in LUA
Moderator: leecollings
-
- 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
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.
-
- 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
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
Best way to go is to either create a device containerscript or use dzvents.
Search the forum for more explanation
- 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
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
-
- 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
ok, didn't know that.
Thanks.
Jan
Thanks.
Jan
-
- 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
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.
-
- 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
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.
- 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
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
Maybe you can post a small example that is giving you an issue?
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- 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
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.
- 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
Understood, but what is the reason you can't use them in LUA?
You stated:
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
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Naming Conventions in LUA
I keep saying this: look at dzVents. Takes care of this.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- 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
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.
- 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
Change that to script_device_window_kitchen.lua and you should be ok.harrykausl wrote: ↑Sunday 24 December 2017 8:46 a script_device_Window_kitchen.lua is not automatically startet.

True, but some of us like to understand and program stuff themselves.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Naming Conventions in LUA
Pick your battles! Why not write C++? Much faster. And gives you even better understanding.
But it’s up to you indeed if you want to spent time with irrelevant, unnecessary and distracting stuff.

But it’s up to you indeed if you want to spent time with irrelevant, unnecessary and distracting stuff.

Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
- 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
I know, that is why I write C++ as well to appreciate LUA and all it error handling.

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- 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
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.
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.
-
- 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
@jvdz - works, thanks!
Who is online
Users browsing this forum: No registered users and 1 guest