Extract data from P1

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
HvdW
Posts: 664
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Extract data from P1

Post 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.
Last edited by HvdW on Wednesday 02 March 2022 13:46, edited 1 time in total.
Bugs bug me.
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Extract data from P1

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 664
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Extract data from P1

Post 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.
Bugs bug me.
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Extract data from P1

Post by waltervl »

Good, DzVents is good documented so always look there first.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 664
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Extract data from P1

Post by HvdW »

I did a search, was on the page before , too superficious.
Lesson learned.
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest