Page 1 of 1

Use globalData in dzvents active test?

Posted: Saturday 13 April 2019 23:18
by doh
Trying to use a globalData value in the active part of a dzvents script to determine whether to run it or not, like this:

Code: Select all

return {

	active = function(domoticz)
			return (domoticz.globalData.variablename ~= '')
	end,
	on = ...
This just errors - looks like it doesn't recognise globalData within the active section:

Code: Select all

2019-04-13 22:16:00.503 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/scripts/dzVents/scripts/test.lua:4: attempt to index field 'globalData' (a nil value)
Is there a way to achieve this?

Thanks

Re: Use globalData in dzvents active test?

Posted: Sunday 14 April 2019 0:49
by waaren
doh wrote: Saturday 13 April 2019 23:18 Trying to use a globalData value in the active part of a dzvents script to determine whether to run it or not

Code: Select all

2019-04-13 22:16:00.503 Error: EventSystem: in /home/pi/domoticz/dzVents/runtime/dzVents.lua: /home/pi/domoticz/scripts/dzVents/scripts/test.lua:4: attempt to index field 'globalData' (a nil value)
Is there a way to achieve this?
Yes. define the variable in the helpers = section of the global_data script and refer to it like

Code: Select all

return {

	active = function(domoticz)
			return (domoticz.helpers.variablename ~= '')
	end,
	on = ...