P1 meter Energy Returned not in Dashtizc

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
Roozen
Posts: 8
Joined: Monday 23 December 2019 17:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Kerkrade, Netherlands
Contact:

P1 meter Energy Returned not in Dashtizc

Post by Roozen »

Dear viewer,

Recently I am experimenting with dashticz and trying to getting familiar with custom graphs.

Problem I have is that I don't get the daily "energy returned" in the dashticz graph.

I am using the below script in config.js for the block definition:

Code: Select all

blocks['P1_Stroom2'] = {
    title: 'Stroom Verbruik',
    devices: [4],
    graph: ['line','line'],
    height: '200px',
    legend: true,
    datasetColors:['blue','green'],
    custom : {
       "Vandaag": {
            range: 'day',
            filter: '24 hours',
            data: {
                verbruik: 'd.eu_4',
                Opgewekt: 'd.eg_4',
            }
        }, 
    },

}
When I check the available parameters for P1 device I can find "eg" as parameter for energy returned

Code: Select all

http://[IP_Adress]:[Port]/json.htm?type=devices&rid=[IDX]
For some reason it does not plot the "eg" values and I get the graph as below
Dashticz_Graph.jpg
Dashticz_Graph.jpg (48.71 KiB) Viewed 1474 times
I would like to get similar graph as in Domoticz:
Domoticz_Graph.jpg
Domoticz_Graph.jpg (29.41 KiB) Viewed 1474 times

What do I do wrong here?
Who can help me with this issue?
Last edited by Roozen on Sunday 17 October 2021 10:52, edited 2 times in total.
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

It's a bug. I'm preparing a fix.


Verstuurd vanaf mijn AC2003 met Tapatalk

Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

Roozen wrote:Dear viewer,

Recently I am experimenting with dashticz and trying to getting familiar with custom graphs.

Problem I have is that I don't get the daily "energy returned" in the dashticz graph.

I am using the below script in config.js for the block definition:

Code: Select all

blocks['P1_Stroom2'] = {
    title: 'Stroom Verbruik',
    devices: [4],
    graph: ['line','line'],
    height: '200px',
    legend: true,
    datasetColors:['blue','green'],
    custom : {
       "Vandaag": {
            range: 'day',
            filter: '24 hours',
            data: {
                verbruik: 'd.eu_4',
                Opgewekt: 'd.eg_4',
            }
        }, 
    },

}
When I check the available parameters for P1 device I can find "eg" as parameter for energy returned

Code: Select all

http://[IP_Adress]:[Port]/json.htm?type=devices&rid=[IDX]
For some reason it does not plot the "eg" values and I get the graph as below
Image

I would like to get similar graph as in Domoticz:
Image



What do I do wrong here?
Who can help me with this issue?
Should be fixed in latest beta 3.8.5. Can you test?

Verstuurd vanaf mijn AC2003 met Tapatalk

Roozen
Posts: 8
Joined: Monday 23 December 2019 17:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Kerkrade, Netherlands
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Roozen »

Perfect.
I updated Dashtics to V3.8.5 today and it works :-)
Thanks for the fast solution
new graph.jpg
new graph.jpg (57.03 KiB) Viewed 1474 times
JakeOfOz
Posts: 9
Joined: Wednesday 31 March 2021 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by JakeOfOz »

Oh nice, I had this issue as well, it works now indeed.
I have another problem though: as is also clear from the last screenshot by @Roozen, the two graphs use separate Y-axes, this makes it less usefull. I tried for a few hours now, but how can you let them use the same axis?
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

I noticed that as well. I'm working on a fix already. And as bonus some new functionality :)

Verstuurd vanaf mijn AC2003 met Tapatalk

jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

Another P1 Energy returned (not wanting to opening another P1-meter topic for a small question)

I have a 3 phase P1-meter and since some time I realize that Domoticz shows wattage values for both return AND usage at the same time, in case the solar panel is feeding in on one phase and the consumption is on the other.

I would like Dashticz to show the total net power value in Watts: usage - return. As soon as that value is negative, I know that my bill is going down :-). Currently I use the energy block with the '_1" addition to it. It shows a negative value when there is return power to the grid, but doesn't count in the usage power on anoter phase.
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

jake wrote: Sunday 12 December 2021 0:42 Another P1 Energy returned (not wanting to opening another P1-meter topic for a small question)

I have a 3 phase P1-meter and since some time I realize that Domoticz shows wattage values for both return AND usage at the same time, in case the solar panel is feeding in on one phase and the consumption is on the other.

I would like Dashticz to show the total net power value in Watts: usage - return. As soon as that value is negative, I know that my bill is going down :-). Currently I use the energy block with the '_1" addition to it. It shows a negative value when there is return power to the grid, but doesn't count in the usage power on anoter phase.
Can you post the Domoticz json device output?

Code: Select all

http://domoticz ip:port/json.htm?type=devices@rid=123
Replace 123 with your Domoticz device id.
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »


Lokonli wrote:
jake wrote: Sunday 12 December 2021 0:42 Another P1 Energy returned (not wanting to opening another P1-meter topic for a small question)

I have a 3 phase P1-meter and since some time I realize that Domoticz shows wattage values for both return AND usage at the same time, in case the solar panel is feeding in on one phase and the consumption is on the other.

I would like Dashticz to show the total net power value in Watts: usage - return. As soon as that value is negative, I know that my bill is going down :-). Currently I use the energy block with the '_1" addition to it. It shows a negative value when there is return power to the grid, but doesn't count in the usage power on anoter phase.
Can you post the Domoticz json device output?

Code: Select all

http://domoticz ip:port/json.htm?type=devices&rid=123
Replace 123 with your Domoticz device id.
The output of the device is:

Code: Select all

{
	"ActTime" : 1639515144,
	"AstrTwilightEnd" : "18:36",
	"AstrTwilightStart" : "06:36",
	"CivTwilightEnd" : "17:11",
	"CivTwilightStart" : "08:01",
	"DayLength" : "07:50",
	"NautTwilightEnd" : "17:55",
	"NautTwilightStart" : "07:17",
	"ServerTime" : "2021-12-14 21:52:24",
	"SunAtSouth" : "12:36",
	"Sunrise" : "08:41",
	"Sunset" : "16:31",
	"app_version" : "2021.1 (build 13872)",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "9202.836",
			"CounterDeliv" : "6239.284",
			"CounterDelivToday" : "0.000 kWh",
			"CounterToday" : "7.606 kWh",
			"CustomImage" : 0,
			"Data" : "4319790;4883046;1846233;4393051;302;0",
			"Description" : "",
			"Favorite" : 1,
			"HardwareDisabled" : false,
			"HardwareID" : 15,
			"HardwareName" : "P1 Smart Meter",
			"HardwareType" : "P1 Smart Meter USB",
			"HardwareTypeVal" : 4,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2021-12-14 21:52:09",
			"Name" : "Electricity",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Energy",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 1,
			"Usage" : "302 Watt",
			"UsageDeliv" : "0 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "142"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
I believe that 'before' either 'usage' or 'UsageDeliv' was supposed to be 0 Watt. Nowadays they both can have a value for a 3 phase meter. I guess this was introduced at the time that I also received additional hardware for each separate phase in domoticz.
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

I've checked the code and you're right. If UsageDeliv > 0 then that value will be shown instead of Usage - UsageDeliv.
I'll create a fix.


Verstuurd vanaf mijn AC2003 met Tapatalk

jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

Lokonli wrote:I've checked the code and you're right. If UsageDeliv > 0 then that value will be shown instead of Usage - UsageDeliv.
I'll create a fix.


Verstuurd vanaf mijn AC2003 met Tapatalk
Hi Lokonli, is the above still on your todo list? If so. No problem. If it is already fixed, how can I implement it?
(if you forgot about it.... please put it on the list) :-)
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

jake wrote:
Lokonli wrote:I've checked the code and you're right. If UsageDeliv > 0 then that value will be shown instead of Usage - UsageDeliv.
I'll create a fix.


Verstuurd vanaf mijn AC2003 met Tapatalk
Hi Lokonli, is the above still on your todo list? If so. No problem. If it is already fixed, how can I implement it?
(if you forgot about it.... please put it on the list) :-)
Please try latest beta :)

Verstuurd vanaf mijn AC2003 met Tapatalk

jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

Lokonli wrote:
jake wrote:
Lokonli wrote:I've checked the code and you're right. If UsageDeliv > 0 then that value will be shown instead of Usage - UsageDeliv.
I'll create a fix.


Verstuurd vanaf mijn AC2003 met Tapatalk
Hi Lokonli, is the above still on your todo list? If so. No problem. If it is already fixed, how can I implement it?
(if you forgot about it.... please put it on the list) :-)
Please try latest beta :)

Verstuurd vanaf mijn AC2003 met Tapatalk
Awesome! I had to wait for a sunny day at home. It works great now in 3.9.0! I only had to change the custom.js file, because this colors the background green when we deliver back to the grid, checking on a UsageDeliv > 0. I have updated that to:

Code: Select all

 function getStatus_142_1(block) {
	if(parseInt(block.device.UsageDeliv - block.device.Usage)>0 ) { //P1-smart meter: electricity usage
		block.addClass= 'background_green';
	}
	else
		block.addClass='';
}
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

jake wrote: Saturday 12 February 2022 12:45 Awesome! I had to wait for a sunny day at home. It works great now in 3.9.0! I only had to change the custom.js file, because this colors the background green when we deliver back to the grid, checking on a UsageDeliv > 0. I have updated that to:

Code: Select all

 function getStatus_142_1(block) {
	if(parseInt(block.device.UsageDeliv - block.device.Usage)>0 ) { //P1-smart meter: electricity usage
		block.addClass= 'background_green';
	}
	else
		block.addClass='';
}
Dashticz 3.9 and 3.9.2
@lokonli, the above .js code no longer works to color the background green as soon as the nett usage < 0, meaning that we deliver more energy than we consume at that moment.
- When I change the calculation back to parseInt(block.device.UsageDeliv)>0 the block turns green when there is delivery at the P1-meter, but the nett usage can be > 0 (for instance when the oven draws 3600W, which is more than my solar system can deliver anytime). In those cases the background should not turn green of course.
- When I change the calculation (only for a test) to parseInt(block.device.Usage)>0 the block turns green when there is usage at the P1-meter.
- to make sure that the usageDeliv is not considered as a negative number, I adapted the code to that as well for a test, but no success: parseInt(block.device.UsageDeliv + block.device.Usage ) < 0 )

I have also tried to modify the code as can be seen here below, since I thought it was possible that block 142_1 (usageDeliv) of th P1-meter might not contain the Usage value. Unfortunately it doesn't help. I simply don't know what the js calculation uses for values for usage and usageDeliv to check the calculation result

Code: Select all

 function getStatus_142(block) {
	if(parseInt(block.device.UsageDeliv - block.device.Usage ) > 0 ) { 
	Dashticz.setBlock('142_1', {
		addClass: 'background_green'
 });
 }
	else
	Dashticz.setBlock('142_1', {
		addClass: ''
	});
}
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

to check the calculation, add the following statement as first line to the code:

Code: Select all

  console.log(block.device);
Then in Chrome open DevTools by pressing F12. Refresh Dashticz. On the DevTools console tab the device info will be visible. If you copy/paste that here we can have a look.
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

If you follow the above, you'll see something like this in the DevTools console tab:

Code: Select all

{
    "AddjMulti": 1,
    "AddjMulti2": 1,
    "AddjValue": 0,
    "AddjValue2": 0,
    "BatteryLevel": 255,
    "Counter": "16344.860",
    "CounterDeliv": "14825.054",
    "CounterDelivToday": "7.994 kWh",
    "CounterToday": "3.332 kWh",
    "CustomImage": 0,
    "Data": "10511199;5833661;4382068;10442986;0;2530",
    "Description": "",
    "Favorite": 1,
    "HardwareDisabled": false,
    "HardwareID": 7,
    "HardwareName": "P1 Smart Meter",
    "HardwareType": "P1 Smart Meter with LAN interface",
    "HardwareTypeVal": 5,
    "HaveTimeout": false,
    "ID": "0001",
    "LastUpdate": "2022-03-03 12:35:41",
    "Name": "Power",
    "Notifications": "false",
    "PlanID": "4",
    "PlanIDs": [
        4,
        3
    ],
    "Protected": false,
    "ShowNotifications": true,
    "SignalLevel": "-",
    "SubType": "Energy",
    "SwitchTypeVal": 0,
    "Timers": "false",
    "Type": "P1 Smart Meter",
    "TypeImg": "counter",
    "Unit": 1,
    "Usage": "0 Watt",
    "UsageDeliv": "2530 Watt",
    "Used": 1,
    "XOffset": "447",
    "YOffset": "81",
    "idx": "43",
    "Data0": "10511199",
    "Data1": "5833661",
    "Data2": "4382068",
    "Data3": "10442986",
    "Data4": "0",
    "Data5": "2530",
    "NettUsage": -2530,
    "NettCounterToday": -4.662,
    "NettCounter": 1519.8060000000005
}
And here you see the problem: Usage and UsageDeliv are both strings with the text 'Watt' at the end: Your subtraction will not work.

Good news: The computed field NettUsage has already been added automatically. You can use this field.

Further, for every subdevice it's 'own' getStatus function will be called as well. You can use this to simplify the code:

Code: Select all

 function getStatus_142_1(block) {      //I've added _1 ! (this this the subdevice)
	if(block.device.NettUsage < 0 )
	    block.addClass='background_green'    //directly manipulate the block itself.
	else
	    block.addClass=''
}
or as oneliner:

Code: Select all

 function getStatus_142_1(block) {      //I've added _1 ! (this this the subdevice)
    block.addClass= block.device.NettUsage < 0  ? 'background_green':'';     //ternary operator
}

jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

Lokonli wrote: Thursday 03 March 2022 12:10 to check the calculation, add the following statement as first line to the code:

Code: Select all

  console.log(block.device);
Then in Chrome open DevTools by pressing F12. Refresh Dashticz. On the DevTools console tab the device info will be visible. If you copy/paste that here we can have a look.
In the devtools I find a console tab, however I wouldn't know how to come across the device info. Anyway, i put the code from your other reply and it works just fine. I had seen the 'Watt' text behind the two parameters, but since the simple calculation usageDeliv>0 worked, I assumed that the 'Watt' text was only added in the browser result for better understanding. I guess that js can handle the number and text, but not for adding and subtracting anymore.
Lokonli
Posts: 2262
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by Lokonli »

jake wrote: Thursday 03 March 2022 14:24
Lokonli wrote: Thursday 03 March 2022 12:10 to check the calculation, add the following statement as first line to the code:

Code: Select all

  console.log(block.device);
Then in Chrome open DevTools by pressing F12. Refresh Dashticz. On the DevTools console tab the device info will be visible. If you copy/paste that here we can have a look.
In the devtools I find a console tab, however I wouldn't know how to come across the device info. Anyway, i put the code from your other reply and it works just fine. I had seen the 'Watt' text behind the two parameters, but since the simple calculation usageDeliv>0 worked, I assumed that the 'Watt' text was only added in the browser result for better understanding. I guess that js can handle the number and text, but not for adding and subtracting anymore.
Nice.

It would have worked with (parseInt(block.device.UsageDeliv) - parseInt(block.device.Usage)).
parseInt ignores the ' watt' addition and just creates a number of the first part.
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: P1 meter Energy Returned not in Dashtizc

Post by jake »

Lokonli wrote: Thursday 03 March 2022 14:31
jake wrote: Thursday 03 March 2022 14:24
Lokonli wrote: Thursday 03 March 2022 12:10 to check the calculation, add the following statement as first line to the code:

Code: Select all

  console.log(block.device);
Then in Chrome open DevTools by pressing F12. Refresh Dashticz. On the DevTools console tab the device info will be visible. If you copy/paste that here we can have a look.
In the devtools I find a console tab, however I wouldn't know how to come across the device info. Anyway, i put the code from your other reply and it works just fine. I had seen the 'Watt' text behind the two parameters, but since the simple calculation usageDeliv>0 worked, I assumed that the 'Watt' text was only added in the browser result for better understanding. I guess that js can handle the number and text, but not for adding and subtracting anymore.
Nice.

It would have worked with (parseInt(block.device.UsageDeliv) - parseInt(block.device.Usage)).
parseInt ignores the ' watt' addition and just creates a number of the first part.
Ah, it seems I was halfway. I should have googled better on the meaning of parseInt. Your explanation makes it now clear for me. Thanks, learning every day (a little bit)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests