Page 1 of 1

'On' condition by an usable array

Posted: Monday 30 October 2017 15:56
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

Re: 'On' condition by an usable array

Posted: Tuesday 31 October 2017 7:28
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
	}
}

Re: 'On' condition by an usable array

Posted: Tuesday 31 October 2017 8:15
by emme
thanks a lot!!!