'On' condition by an usable array

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

Moderator: leecollings

Post Reply
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

'On' condition by an usable array

Post by emme »

Ciao,

quick question....
it is might possible to define an array in the ON condition and use it in the code?
something like....

Code: Select all

local arrDevice = { 'myDev1', 'myDev2' },
On = devices{{ arrDevice }},
execute=funtion(domoticz, device)
   domoticz.log(arrDevice[1])
end
The most dangerous phrase in any language is:
"We always done this way"
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: 'On' condition by an usable array

Post by dannybloe »

This should work famous last words:

Code: Select all

local myDevices = { 'devA', 'devB', 'devC' }

return {
	on = {
		devices = myDevices
	},
	execute = function(dz, d) {
		print(myDevices[1]) -- gives devA
	}
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: 'On' condition by an usable array

Post by emme »

thanks a lot!!!
The most dangerous phrase in any language is:
"We always done this way"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest