Meters combination Topic is solved

Moderators: leecollings, htilburgs, robgeerts

Post Reply
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Meters combination

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

Re: Meters combination

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

Re: Meters combination

Post 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?
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Meters combination

Post 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.
Attachments
Naamloos.jpg
Naamloos.jpg (21.05 KiB) Viewed 3897 times
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Meters combination

Post 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.
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Meters combination

Post 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.
Attachments
dash.png
dash.png (5.78 KiB) Viewed 3869 times
blocks.js
(72.04 KiB) Downloaded 153 times
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Meters combination

Post 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.
Attachments
blocks 2020-05-08.js
(71.92 KiB) Downloaded 163 times
Lokonli
Posts: 2260
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Meters combination

Post 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 :)
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Meters combination

Post 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';
}
Lokonli
Posts: 2260
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Meters combination

Post by Lokonli »

Change the block.value line to:

Code: Select all

block.value = (valueA - valueB).toFixed(2) + ' kWh';
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Meters combination

Post by dorenberg »

yes, that does the trick. Kudos!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest