Page 1 of 1

[SOLVED] Domoticz/.getAllVariables() ?

Posted: Thursday 09 March 2023 18:01
by Grunnpi
Hi there,

I'm trying to build a block content based on a water meter device, and two variables content.
I was planning to perform such things in "custom/.js" with something like

Code: Select all

function afterGetDevices(){
	var var1 = Domoticz/.getAllDevices()['vVar1'];
	var var2 = Domoticz/.getAllDevices()['vVar2'];
	var waterMeter = Domoticz/.getAllDevices()['123'];
		
	Dashticz/.setBlock('target_block', {
		title: 'Water Left ' + var1/.value + var2/.value - waterMeter/.usage
	});
}
But no "getAllVariables()" as far as I understand.

Any idea or tips to share please ?

Re: Domoticz/.getAllVariables() ?

Posted: Thursday 09 March 2023 20:06
by Lokonli
You can get Domoticz variable values via Domoticz.getAllDevices()['v123'];

So, put 'v' in front of the variable index.

Re: Domoticz/.getAllVariables() ?

Posted: Friday 10 March 2023 10:07
by Grunnpi
Oh great !
I did try but then, I tried var1/.value but didn’t return anything.
Is there something to do regarding variable type ? (String, int, …)

Re: Domoticz/.getAllVariables() ?

Posted: Friday 10 March 2023 19:20
by Lokonli
It is case sensitive. Try:

Code: Select all

var1.Value
During debugging you could add:

Code: Select all

console.log(var1);
then in Devtools (Press F12) console tab you see the debug messages.

Re: [SOLVED] Domoticz/.getAllVariables() ?

Posted: Friday 10 March 2023 22:53
by Grunnpi
Thanks a lot, exactly what I was looking for !