Page 1 of 1
Variable with sub IDX
Posted: Sunday 25 October 2020 19:44
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??
Re: Variable with sub IDX
Posted: Sunday 25 October 2020 22:30
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
Re: Variable with sub IDX
Posted: Wednesday 28 October 2020 18:53
by michelscholte
This is exacly what I mean and it works. Thanks a lot.