[SOLVED] Domoticz/.getAllVariables() ?

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
Grunnpi
Posts: 3
Joined: Thursday 09 March 2023 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

[SOLVED] Domoticz/.getAllVariables() ?

Post 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 ?
Last edited by Grunnpi on Friday 10 March 2023 22:52, edited 1 time in total.
Lokonli
Posts: 2290
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz/.getAllVariables() ?

Post by Lokonli »

You can get Domoticz variable values via Domoticz.getAllDevices()['v123'];

So, put 'v' in front of the variable index.
Grunnpi
Posts: 3
Joined: Thursday 09 March 2023 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz/.getAllVariables() ?

Post 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, …)
Lokonli
Posts: 2290
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz/.getAllVariables() ?

Post 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.
Grunnpi
Posts: 3
Joined: Thursday 09 March 2023 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Grunnpi »

Thanks a lot, exactly what I was looking for !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest