Variable with sub IDX Topic is solved

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
michelscholte
Posts: 75
Joined: Friday 08 January 2016 10:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Nederland
Contact:

Variable with sub IDX

Post by michelscholte »

I have a lot of variables in Domoticz like this "0|0|Er staat niets open. Geen regen verwacht.|10|666666".
I would like to get the different elements from this variable, just like a Temp/Hum sensor. For example v123_1 or v123_3 . Is that possible??
Lokonli
Posts: 2292
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Variable with sub IDX

Post by Lokonli »

michelscholte wrote: Sunday 25 October 2020 19:44 I have a lot of variables in Domoticz like this "0|0|Er staat niets open. Geen regen verwacht.|10|666666".
I would like to get the different elements from this variable, just like a Temp/Hum sensor. For example v123_1 or v123_3 . Is that possible??
You could create a custom getStatus function in custom.js:

Code: Select all

function getStatus_myvar0(block) {
	block.value = block.device.Value.split('|')[0];	//to get the first part of the variable value
 }

function getStatus_myvar1(block) {
	block.value = block.device.Value.split('|')[1];	//to get the second part of the variable value
 }
 
This assumes you have defined your blocks in CONFIG.js as follows (replace 123 with your variable idx):

Code: Select all

blocks['myvar0'] = {
   idx: 'v123'
 }

blocks['myvar1'] = {
   idx: 'v123'
 }
If you would like to have a more fancy block, you could create one via getBlock in custom.js. For an example see:
https://dashticz.readthedocs.io/en/mast ... -idx-block
michelscholte
Posts: 75
Joined: Friday 08 January 2016 10:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Nederland
Contact:

Re: Variable with sub IDX

Post by michelscholte »

This is exacly what I mean and it works. Thanks a lot.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest