Feature request: Include

Easy to use, 100% Lua-based event scripting framework.
Post Reply
poudenes
Posts: 511
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Feature request: Include

Post by poudenes » Wednesday 07 March 2018 13:58

Hi All,

In many scripts i have local variables to define devices.
Maybe its a idea to have 1 lua file that keeps all de local variables collection you use in all your scripts.

Then every script will have only 1 line to have the locals

include "locallist.lua" or include "/home/pi/domoticz/scripts/dzVents/scripts/local.lua"

i tried the include and require but get lot of errors ;)

Cheers,
Peter
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

dannybloe
Posts: 1461
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Feature request: Include

Post by dannybloe » Wednesday 07 March 2018 14:48

Better put it in global_data and add it to the helper section. Then it is available in all your files. See the documentation about global_data and helper functions.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

dannybloe
Posts: 1461
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Feature request: Include

Post by dannybloe » Wednesday 07 March 2018 14:56

Besides you can also put files in dzVents/scripts/modules and require from there. It's in the package path.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

poudenes
Posts: 511
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Feature request: Include

Post by poudenes » Wednesday 07 March 2018 15:14

hmm ok. only what i want is have this list (original is longer) so i can use them in every script. Instead to add them in every script.

Code: Select all

local SceneDaytime	= domoticz.devices(82)
local SceneEvening = domoticz.devices(83)
local SceneTV = domoticz.devices(84)
local SceneMovie = domoticz.devices(85)
local SceneAppleTV = domoticz.devices(86)
local SceneSexy = domoticz.devices(87)
local SceneMorning = domoticz.devices(88)
local SceneGoodnight = domoticz.devices(89)
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

poudenes
Posts: 511
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Feature request: Include

Post by poudenes » Wednesday 07 March 2018 15:34

and there is no dzVents/scripts/modules folder. Doc: /path/to/domoticz/scripts/dzVents/modules or /path/to/domoticz/scripts/dzVents/scripts/modules
both are not there
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

User avatar
waaren
Posts: 791
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Feature request: Include

Post by waaren » Thursday 08 March 2018 10:08

poudenes wrote:
Wednesday 07 March 2018 15:34
and there is no dzVents/scripts/modules folder. Doc: /path/to/domoticz/scripts/dzVents/modules or /path/to/domoticz/scripts/dzVents/scripts/modules
both are not there
Hopefully you realized by now that you have to create that subdirectory yourself ?
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

dannybloe
Posts: 1461
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Feature request: Include

Post by dannybloe » Thursday 08 March 2018 10:18

poudenes wrote:
Wednesday 07 March 2018 15:14
hmm ok. only what i want is have this list (original is longer) so i can use them in every script. Instead to add them in every script.

Code: Select all

local SceneDaytime	= domoticz.devices(82)
local SceneEvening = domoticz.devices(83)
local SceneTV = domoticz.devices(84)
local SceneMovie = domoticz.devices(85)
local SceneAppleTV = domoticz.devices(86)
local SceneSexy = domoticz.devices(87)
local SceneMorning = domoticz.devices(88)
local SceneGoodnight = domoticz.devices(89)
This is not going to work as the domoticz object is only locally available inside your execute function (parameter). So if you would require that shared module with these declarations then there is no domoticz object. And.. you declare them local so they would only be local to your module (but that's beside the point).
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

poudenes
Posts: 511
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Feature request: Include

Post by poudenes » Thursday 08 March 2018 11:01

waaren wrote:
Thursday 08 March 2018 10:08
poudenes wrote:
Wednesday 07 March 2018 15:34
and there is no dzVents/scripts/modules folder. Doc: /path/to/domoticz/scripts/dzVents/modules or /path/to/domoticz/scripts/dzVents/scripts/modules
both are not there
Hopefully you realized by now that you have to create that subdirectory yourself ?
yep :)
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

poudenes
Posts: 511
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Feature request: Include

Post by poudenes » Thursday 08 March 2018 11:01

dannybloe wrote:
Thursday 08 March 2018 10:18
poudenes wrote:
Wednesday 07 March 2018 15:14
hmm ok. only what i want is have this list (original is longer) so i can use them in every script. Instead to add them in every script.

Code: Select all

local SceneDaytime	= domoticz.devices(82)
local SceneEvening = domoticz.devices(83)
local SceneTV = domoticz.devices(84)
local SceneMovie = domoticz.devices(85)
local SceneAppleTV = domoticz.devices(86)
local SceneSexy = domoticz.devices(87)
local SceneMorning = domoticz.devices(88)
local SceneGoodnight = domoticz.devices(89)
This is not going to work as the domoticz object is only locally available inside your execute function (parameter). So if you would require that shared module with these declarations then there is no domoticz object. And.. you declare them local so they would only be local to your module (but that's beside the point).
Ah ok. Thanks. Then i'll let it as it is :)
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests