Query P1 database with JSON

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

Moderator: leecollings

Post Reply
Gingerpale
Posts: 40
Joined: Wednesday 13 January 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Query P1 database with JSON

Post by Gingerpale »

Hi,
My current energy script filters the P1 meter log database per year and searches for specific dates in that year.
[url]http://<IPaddr>:<Port>/json.htm?type=command&param=graph&sensor=counter&idx=12345&range=year&year=2026[/url]
It returns the whole year, but filtering for 2026-01-01 it returns:

Code: Select all

{
			"c" : "6409.15",
			"d" : "2026-01-01",
			"p" : "11.8244",
			"v" : "9.91"
		},
So this works but queries a large JSON response.

Since I am only looking for data at one specific date (day of the year), I thought I could also do:
[url]http://<IPaddr>:<Port>/json.htm?type=command&param=graph&sensor=counter&idx=12345&range=2026-01-01T2026-01-01[/url]
However, in this case not all data is present, I get (only showing "result" section below), so "c" and "p" are missing:

Code: Select all

	"result" : 
	[
		{
			"d" : "2026-01-01",
			"v" : "9.91"
		},
		{
			"d" : "2026-01-01",
			"v" : "20.11"
		}
	],
What thinking error do I make?
Ultimately I want to fetch the data of the P1 meter for one specific day of the year (e.g. contract start date).

Any idea's?
Rpi4B,RFX433e,PiFace2, LCD, Hue bridge, Alexa (+TTS), HA-Bridge, Sonoff NSPanel, Sonoff RF (+IR) bridge, Nefit CV, Tasmota/MQTT, Enphase Solar, Smartmeter, Alarm I/F, H13726B Weather Station, CM180 Energy meter, Sonoff, KaKu, Tuya, Gledopto, AriLux,...
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Query P1 database with JSON

Post by waltervl »

What if you range from the contract date till today? You also only see the d and v value?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
gizmocuz
Posts: 2706
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Query P1 database with JSON

Post by gizmocuz »

Another option, use the web gui. Click on your P1 meter, at the top click 'Report', then click on the right month to see a report by day
You ask for yearly data, so you get a year.. you can also query for the last month, has less values
Quality outlives Quantity!
Gingerpale
Posts: 40
Joined: Wednesday 13 January 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: Query P1 database with JSON

Post by Gingerpale »

@ waltervl If I range from contract date start till today it also only gives the d and v values back.
@gizmocuz I use this in a Dzvents script to calculate something like total counter = today counter - start counter, so using &range=year is nice as it gives values per day. As my script fetches quite a lot of JSON data every time and I had the issue with the callback function in other post, I figured it would be good to query for less JSON data or for exactly the data I need without fetching all the other useless data and searching through it.
Range felt like a good option but strangely enough it only fetches part of the data I need, actually I need the "c" which it doesn't fetch.
So I just wondered if I made a mistake or anything?
Rpi4B,RFX433e,PiFace2, LCD, Hue bridge, Alexa (+TTS), HA-Bridge, Sonoff NSPanel, Sonoff RF (+IR) bridge, Nefit CV, Tasmota/MQTT, Enphase Solar, Smartmeter, Alarm I/F, H13726B Weather Station, CM180 Energy meter, Sonoff, KaKu, Tuya, Gledopto, AriLux,...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest