Query to Obtain Statistics/Sum/Integral

Currently I get the sum of any given input/output by retrieving the records within a specified range, looping and totaling each record then converting this total to kWh. The net result always matches the amount of the Statistics/Sum Integral on the iotaWatt Graph+ page.

Is there a query that can accomplish the same without having to retrieve, loop and total each record within the specified range?

Sure. Lets say I want to know how many Watt Hours my refrigerator used last week:



So it used 13,330 Wh or 13.330 kWh

1 Like

Ok, now this is interesting. I havent seen the use of .wh before. When I tried the query http://iotawatt.local/query?format=csv&select=[time.iso,Main]&begin=d&end=s&group=all I got a bizarre number I couldnt make sense of… When I added the .wh all was good and got the correct number. So what is the number I am getting when I query without the .wh??? I am going to guess its an average/hour

It’s average Watts over the period. In your case average Watts today.

The docs cover all of the units available.

Hey Bob - sorry to hijack - but it is directly related

In my case i am using[time.iso,Grid.wh]&begin=w-1w&end=w&group=all

To get the amount that i have (theoretically) drawn from the Grid in a current 1 week period.

In my case i have Solar and a large battery system - so if i am feeding the grid does this reduce the total or are the numbers all treated as absolute and summed together ?

When i feed the grid the values show up and negative in my IOTAWATT main screen and positive when i draw from the grid.


If you only want the energy imported, that is the sum of the positive Grid and not the net, you should setup an integration to sum the positive and negative components of your grid feed. Then, as the docs show, creat an output that is the positive component and query that.

Good one thanks - will read up on the integration setup etc

thanks once again for great support