Page 1 of 1
Meters combination
Posted: Monday 04 May 2020 15:40
by dorenberg
Hi all,
I just wanted to ask if there would be an option to merge 2 values from a P1 meter. The current usage only reflects one value. The return is not seen in Dashticz or is reported in a positive value. Very confusing. It is possible to do this in the graph section, which works rather fine!
To explain it a bit more, my p1 meter in domoticz reports 99watt (usage), -1517watt (return). I only see the last number reported in dashticz, and it is always positive. I would like to report 99-1517 = -1418watt in this example.
Re: Meters combination
Posted: Monday 04 May 2020 23:24
by Lokonli
Your P1 meter cannot have a usage value and a usagedeliv value at the same time ...
Can you explain what you would like to see?
Re: Meters combination
Posted: Monday 04 May 2020 23:26
by Lokonli
Your P1 meter cannot have a usage value and a usagedeliv value at the same time ...
Can you explain what you would like to see?
Re: Meters combination
Posted: Tuesday 05 May 2020 10:02
by dorenberg
Yes, it is definitely possible. I have a 3-phase connection. Return is on phase number 1 only. But there is usage on the other 2 phases (also on phase 1). These are reported in the p1 meter as the netto usage on phase 1 (which can be return), and if that is the case 2 values are reported. See attachment jpg.
Re: Meters combination
Posted: Tuesday 05 May 2020 14:21
by jake
My p1 meter generated 7 devices: 2x L1/2/3 and 1 that produces a string of information: meter values and current usage/return values. That last device is used in my dashticz.
Re: Meters combination
Posted: Tuesday 05 May 2020 16:23
by dorenberg
In Domoticz I have 3 voltage sensors, 3x return and 3x usage. And the current use as pictured above and totals.
I have managed to get both values in one block. Now the question, how to substract both from each other. Usage-UsageDeliv.
Re: Meters combination
Posted: Friday 08 May 2020 15:16
by dorenberg
Solved it. Attached the blocks.js
function getSmartMeterBlock(block) {
var device = block.device;
var idx = device.idx;
block.width = block.width || 4;
if (device['SubType'] === 'Energy') {
var value1=parseFloat(device['Usage']);
var value2=parseFloat(device['UsageDeliv']);
var usage = value1 - value2 + 'Watt';
Now I only get the nett use or return. Both substracted from each other.
Re: Meters combination
Posted: Friday 08 May 2020 17:06
by Lokonli
dorenberg wrote: ↑Friday 08 May 2020 15:16
Solved it. Attached the blocks.js
function getSmartMeterBlock(block) {
var device = block.device;
var idx = device.idx;
block.width = block.width || 4;
if (device['SubType'] === 'Energy') {
var value1=parseFloat(device['Usage']);
var value2=parseFloat(device['UsageDeliv']);
var usage = value1 - value2 + 'Watt';
Now I only get the nett use or return. Both substracted from each other.
I would not recommend modifying blocks.js, because if there is a Dashticz update you have to reapply your changes, and updating may be more difficult.
There is an easier way, that works for most devices. (assuming you run a recent beta version of Dashticz)
If you Domoticz device id is 43, and has subdevices (like a smartmeter), add subdevice '43_1' to a Dashticz column, and the following to custom.js:
Code: Select all
function getStatus_43_1(block) {
var device = block.device;
var value1=parseFloat(device['Usage']);
var value2=parseFloat(device['UsageDeliv']);
block.value = value1 - value2 + ' Watt';
}
And then as weekend bonus: If you have solar panels, and you would like to know your actual energy usage, then you can compute it with (pseudocode):
P1meter _in + Solar - P1meter_out.
and in real, assuming your Solar panes are a energy device, with device ID 6:
Code: Select all
function getStatus_43_1(block) {
var device = block.device;
var value1=parseFloat(device['Usage']);
var value2=parseFloat(device['UsageDeliv']);
var solar = Domoticz.getAllDevices()[6];
var value3=parseFloat(solar['Usage']);
var nettusage = value1 + value3 - value2;
block.value = 'Usage: ' + nettusage;
}
As you can see you have access to other Domoticz device data as well, which you can use to create your block.value
Enjoy

Re: Meters combination
Posted: Sunday 10 May 2020 16:38
by dorenberg
thanks for this. I just changed it to your suggestion and it works perfect.
I also wanted to do this for the nett usage per day. But sometimes I get values with a lot of decimals (15 or so). How can I fix this to 2 decimals? Learning js every day.
function getStatus_62_2(block) {
var device = block.device;
var valueA=parseFloat(device['CounterToday']);
var valueB=parseFloat(device['CounterDelivToday']);
block.value = valueA - valueB + ' kWh';
}
Re: Meters combination
Posted: Sunday 10 May 2020 17:30
by Lokonli
Change the block.value line to:
Code: Select all
block.value = (valueA - valueB).toFixed(2) + ' kWh';
Re: Meters combination
Posted: Sunday 10 May 2020 18:21
by dorenberg
yes, that does the trick. Kudos!