Query API output wh averaging not summing

Hi,

I purchased an iotawatt unit from at the beginning of the year and have been impressed so far.

I’ve integrated the data into Homeassistant using the query api. In doing this, i setup a number of outputs (e.g. solar going back into grid, solar self consumption etc). On the homeassistant side, i’m querying the total wh per day, and according to the docs, this should be a sum (rather than average) in the case of wh. When querying the day in a single value, the number returned slowly goes down at night (when no solar is being generated) - and so i’m thinking this number might be averaged in the cased of an output (it works as i would expect as an input though).

Am i doing something wrong / have the wrong expectations here or is this a genuine problem?

query i’m using:
http://192.168.1.134/query?select=[solar_to_grid.wh]&begin=2020-03-01&end=s&group=all

Cheers
Alex

Hello Alex,
Can you post the output setup display so I can see how solar_to_grid is calculated?

Sure - here’s the calculation

Hi Alex,

I understand what you are trying to do, but there is no direct way to do this with query. It’s true the Wh delivers totals, but not in the way you expect.

For the sake of simple explanation, let me restate your formula as:

export = 0 max (solar - usage)

In the query, you repeatedly request this value for the current day from midnight to the present as a single group=all value. The way IoTaWatt evaluates this on each request is to insert the current total value of both solar and usage into the formula. So after the sun goes down, solar does not change, but usage continues to increase. The result is what you are seeing: the export number decreases.

I think what you intend to happen is to integrate that function over all of the measurements of the day. IoTaWatt doesn’t do that. First because there is no way to specify that should be done, but also because it would be very time consuming to read and process over 17,000 measurements to do that. What it does now involves reading and processing two measurements.

I’ve been contemplating how to add the ability to store cumulative import and export to the IoTaWatt, but have not yet come up with a satisfactory solution.

Currently, any of the three supported servers are capable of developing this integrated export number from the data that is exported. They are hosted on servers that can easily do this analytic work. IoTaWatt is designed to produce raw data, not do retrospective analysis on that data.

Hope that helps.

Ahh ok - thanks. I’ll look to running a DB to make these calculations.

Thanks!

(BTW - your support was the selling point for me when deciding whether to roll my own or purchase from you)

Awhile back I worked out a somewhat convoluted way to accumulate the exported (negative) energy. It involves using both a signed (allow negative values) and unsigned CT on a main.

In a split phase system, you have two mains. If you don’t really need to know the individual measurements of the two mains (only interested in the total) and the total doesn’t exceed 200Amps, it would be possible to do by using a splitter to combine the mains and some under the hood sleight of hand to share the combined CTs between two inputs.

The just of it is that the two mains are combined with the splitter and fed into Input_1. Allow negative values is set and the single input delivers what was Main1 + Main2. Well cal that netMain because it will accumulate the net power through the mains.

A manually inserted config file parameter makes Input_2 use the CT plugged into Input_1. It is configured without the “allow negative” check so it accumulates the sum of the imported and exported power as a positive number. Well call that absMain.

So now energy for netMain is import-export.

Energy for absMain is import+export.

netMain - absMain = (import - export) - (import + export) = 2 * export.

The calculator function

export = (netMain - absMain) / 2. Over any interval - hours, days, months.

I dont have solar, I have trees, so I have not been able to try this at home. I believe a guy in Australia is doing it but I lost track of that effort. If your mains don’t come close to 200A combined, and you want to try it out, I can send you a splitter and help you set it up.