Page 1 of 1

Extract data from P1

Posted: Wednesday 02 March 2022 13:22
by HvdW
Here is the data dump from P1

Code: Select all

{
	"ActTime" : 1646222947,
	"AstrTwilightEnd" : "20:07",
	"AstrTwilightStart" : "05:24",
	"CivTwilightEnd" : "18:48",
	"CivTwilightStart" : "06:43",
	"DayLength" : "10:57",
	"NautTwilightEnd" : "19:27",
	"NautTwilightStart" : "06:04",
	"ServerTime" : "2022-03-02 13:09:07",
	"SunAtSouth" : "12:45",
	"Sunrise" : "07:17",
	"Sunset" : "18:14",
	"app_version" : "2022.1",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "41302.327",
			"CounterDeliv" : "30324.101",
			"CounterDelivToday" : "3.904 kWh",
			"CounterToday" : "10.114 kWh",
			"CustomImage" : 0,
			"Data" : "26879169;14423158;8768692;21555409;0;2900",
			"Description" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 4,
			"HardwareName" : "P1 smart meter",
			"HardwareType" : "P1 Smart Meter USB",
			"HardwareTypeVal" : 4,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2022-03-02 13:09:02",
			"Name" : "Power",
			"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" : "0 Watt",
			"UsageDeliv" : "2900 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "15"
		}
	],
	"status" : "OK",
	"title" : "Devices"
I am looking at these data.

Code: Select all

			"Usage" : "0 Watt",
			"UsageDeliv" : "2900 Watt",
I can extract Usage with

Code: Select all

        local power_usage = dz.devices(POWER).usage
        
However I cannot extract Delivery to the net.

Code: Select all

 local power_delivery = dz.devices(POWER).usagedeliv
The extraction of data executes without error

Code: Select all

dz.log('Delivery   : ' .. power_delivery, dz.LOG_DEBUG)
However the debug info tells me: cannot concatenate a nil value

The usage gives me values from 0 up to 3000 and more
The delivery, indicated as 2900 gives me this NIL value.

What is the secret code to use other than usagedeliv or change that NIL value bug.

Re: Extract data from P1

Posted: Wednesday 02 March 2022 13:45
by waltervl
See the documentation https://www.domoticz.com/wiki/DzVents:_ ... mart_meter
P1 Smart meter
counterDeliveredToday: Number.
counterToday: Number.
usage1, usage2: Number.
return1, return2: Number.
updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options.
usage: Number.
usageDelivered: Number.

Re: Extract data from P1

Posted: Wednesday 02 March 2022 14:17
by HvdW
In fact I am searching for the word UsageDelivered or Delivery or like the code displays UsageDeliv.
None of those delivers a number.
Your link displayed the magic word usageDelivered

It works!
Thanks for the help.

Re: Extract data from P1

Posted: Wednesday 02 March 2022 16:21
by waltervl
Good, DzVents is good documented so always look there first.

Re: Extract data from P1

Posted: Wednesday 02 March 2022 23:08
by HvdW
I did a search, was on the page before , too superficious.
Lesson learned.