Page 1 of 1
Concat 2 values in dash?
Posted: Sunday 10 September 2023 17:47
by magicduck
Hello,
I have 2 PV counters on Domoticz, and I would like to concat the power generated into 1 values.
Code: Select all
var CPV = 3934;
var CPV2 = 6022;
// ...
blocks[CPV] = {
title: 'PV',
idx: CPV+'_1',
icon: 'fas fa-solar-panel',
unit: ' Watts',
};
blocks[CPV2] = {
title: 'PV Mur',
idx: CPV2+'_1',
icon: 'fas fa-solar-panel',
unit: ' Watts',
};
I really would like to have "one" block for the 2 blocks... is this possible ?
Regards
Re: Concat 2 values in dash?
Posted: Sunday 10 September 2023 22:02
by Lokonli
For a dial it's supported. See:
https://dashticz.readthedocs.io/en/mast ... ial-values
For a regular block it's not supported. Maybe I'll add it in the future.
You could create a text device in Domoticz. With a small (dzVents) script, you can combine the data of the two devices.
Re: Concat 2 values in dash?
Posted: Monday 11 September 2023 18:11
by magicduck
Well... This is not really what I was looking for... But... mostly (on my example) something like :
Code: Select all
blocks['PV] = {
title: 'PV',
icon: 'fas fa-solar-panel',
unit: ' Watts',
values:[
{
idx: CPV+'_1',
},
{
idx: CPV2+'_2',
},
],
mathvalues: 'sum',
In this case is we have in CPV_1 = 300 (Watts), and CPV2_1 = 1000 (Watts), the block will display 1300 Watts.
Re: Concat 2 values in dash?
Posted: Monday 11 September 2023 19:47
by Lokonli
If you want to show the sum of 2 values you can do it as follows:
Define a block. Something like:
Code: Select all
blocks['combined'] = {
title: 'combined',
idx: '3934_1',
value: 'test',
unit:''
}
Then in custom.js add the following:
Code: Select all
var val1=0;
var val2=0;
function updateBlock() {
// console.log(val1, val2);
Dashticz.setBlock('combined', {
value: ''+(val1+val2)+' kWh'
});
}
function deviceHook(device) {
if (device.idx==3934) {
val1=parseFloat(device.Data0);
updateBlock();
}
if (device.idx==6022) {
val2=parseFloat(device.Data0);
updateBlock();
}
}
If you want to show both values (on one line), change custom.js to:
Code: Select all
var val1=0;
var val2=0;
function updateBlock() {
Dashticz.setBlock('combined', { //Example how to redefine another block
value: val1+' '+val2+' kWh'
});
}
function deviceHook(device) {
if (device.idx==3934) {
val1=device.Data0;
updateBlock();
}
if (device.idx==6022) {
val2=device.Data0;
updateBlock();
}
}