Energy, Gas, Water JSON/API question/answer suggestion. Topic is solved

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
Kosu77
Posts: 1
Joined: Wednesday 31 January 2024 0:36
Target OS: Linux
Domoticz version:
Contact:

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

Post 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
willemd
Posts: 621
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

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

Post by willemd »

You can export to a spreadsheet with the hamburger menu top right.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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.
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
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
pa1apw
Posts: 1
Joined: Friday 09 August 2024 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by pa1apw »

where can i add this command to get the results
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post by waltervl »

In whatever python script, dvents script etc where you want to use this......
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
infoed
Posts: 7
Joined: Monday 21 October 2024 14:33
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

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

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest