dzVents global variables

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Inso
Posts: 7
Joined: Thursday 12 October 2017 23:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

dzVents global variables

Post by Inso »

Hi,

my lua script had some IP adresses as local variables, f.e.

Code: Select all

local IPR1 = {'192.168.178.44', '192.168.178.49', '192.168.178.50', '192.168.178.48'}
PORT = '55443'
       for n, IP in pairs(IPR1) do
               runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",4,1,\"500,1,16711680,1,    900000,7,0,0, 900000,2,1700,1, 900000,2,1700,100 \"]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."&";;     os.execute(runcommandoff);
On dzVents, within the execute function, it also works fine. Now i´d like to set them as global variables, as they are not changed and used often. Seems they are recognized as floating numbers, I found no way to get 'em to work the same way as in the execute function.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents global variables

Post by dannybloe »

Read the documentation about global helper functions. You can use it also for other stuff. In your global_data.lua add this:

Code: Select all

return {
	helpers = {
		IPR1 = {'192.168.178.44', '192.168.178.49', '192.168.178.50', '192.168.178.48'}
	}
}
In another script you can use it like this:

Code: Select all

print(domoticz.helpers.IPR1[1]) -- will print 192.168.178.44
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest