Page 1 of 1

Global USer Variables type

Posted: Friday 09 February 2018 15:37
by emme
Ciao
could it be possible to evaluate to implement new kind of user Variables?
In particular a boolean (True, False) and a json/table object type could be really helpful!

I have few script that uses tables as config paramenters, but since they are within the scripts it is quite unconfortable to edit the script to fine tune parameters

I was looking for a different approach and user variables are the best way, but I have to set them up as strings and then convert into the script....

I would be nice to have them already in this way... unfortunately also a JSON viewer/editor/validator should be implemented

ciao
M

Re: Global USer Variables type

Posted: Friday 09 February 2018 17:56
by dannybloe
I know you use dzVents so why not use the gui editor and create a dzvents script (module) with all the values and require that data inside your script?

In a script 'my-config':

Code: Select all

return {
	setting1 = 10, 
	setting2 = 20
}
In a dzVents script:

Code: Select all

return {
	..
	execute = function(dz, item)
		local config = require('my-config.lua')
		print(config.setting1)
	end
}
or something like that. You can do all of this in domoticz gui.

Re: Global USer Variables type

Posted: Friday 09 February 2018 18:35
by emme
This is EXACTLY what I was looking for :D :D

Thanks so much!!

Re: Global USer Variables type

Posted: Friday 09 February 2018 19:13
by dannybloe
Or better: add some config to global_data.helpers and you don’t have to use require at all. See the docs.