Page 1 of 1

Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Wednesday 31 January 2024 1:16
by Kosu77
Hi
Inquiry for energy meter:

Code: Select all

?type=graph&sensor=counter&idx=IDX&range=year
returns totals for specific days but for the entire year.

I have a suggestion to add the option to provide a parameter from what date it should count, i. e.:

Code: Select all

?type=graph&sensor=counter&idx=IDX&range=year&date=2024-01-29
Domoticz nicely sums the values from a given period, and due to the fact that not everyone is interested in the sum of values ​​from the period from a year to the present, only from a specific date. If only because of settlement periods.
Regards

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Wednesday 31 January 2024 8:28
by willemd
You can export to a spreadsheet with the hamburger menu top right.

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Wednesday 31 January 2024 8:33
by waltervl
This API was designed to be used for creating the graphs in Domoticz. For this usage there is no need to add your feature request.
You always can use a script to get these data out for a specific date range.

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Friday 21 June 2024 19:05
by waltervl
It seems it was already implemented but not documented yet.....
For counter you can use a data range, notice the "T" between the dates:

Code: Select all

/json.htm?type=command&param=graph&sensor=counter&idx=IDX&range=YYYY-MM-DDTYYYY-MM-DD

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Saturday 10 August 2024 0:16
by pa1apw
where can i add this command to get the results

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Saturday 10 August 2024 17:26
by waltervl
In whatever python script, dvents script etc where you want to use this......

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Monday 21 October 2024 14:56
by infoed
Hi, I'm looking for one API call where I can see the daily usage and the counters for both the "result" as the "prevresult" payload.
Purpose is to get an calculation of yearly usage based on "to day".

I've noticed that sometimes the dayly usage calculation, every night by domitcz, is returning different values than the counters presents!

The counters itself are not returned in the prevsult part when using &range=year. The daily usage is.
And also are not retrieved when specifing a range : &range=YYYY-MM-DDTYYYY-MM-DD.

The only option I could find is to do TWO API calls:
json.htm?type=graph&sensor=counter&idx=..&range=year&actyear=2024
json.htm?type=graph&sensor=counter&idx=5&range=year&actyear=2023
In both datasets I get the counters ("c") and the daily usage ("v").

The problem here is that you have to do your calculations (my case: calculate past year usage, starting from to day) in a more complex way than when you have one .

Re: Energy, Gas, Water JSON/API question/answer suggestion.

Posted: Monday 21 October 2024 15:26
by waltervl
infoed wrote: Monday 21 October 2024 14:56
The counters itself are not returned in the prevsult part when using &range=year. The daily usage is.
And also are not retrieved when specifing a range : &range=YYYY-MM-DDTYYYY-MM-DD.
.......
The problem here is that you have to do your calculations (my case: calculate past year usage, starting from to day) in a more complex way than when you have one .
When you have all the daily usage in your preferred range (past year usage, starting from to day) you can add them all up to get the total result. No need to have the counters.

Edit: Here a dzvents example: viewtopic.php?p=193393#p193393