I accumulate data from my inverter on the daily PV production. I wanted to create a query to summarize production for each of the last 12 months. I have a problem with the current day: seems that it does not add the current day production to the current month.
The query I'm using is:
from(bucket: "home")
|> range(start: -1y)
|> filter(fn: (r) =>
r._measurement == "inverter" and
(r._field == "Power_PV_Generation_Today")
)
|> aggregateWindow(every: 1d, offset: -1h1m, fn: last, createEmpty: false)
|> aggregateWindow(every: 1mo, fn: sum, createEmpty: true)
Power_PV_Generation_Today is a value extracted from the inverter and it resets at midnight - hence I'm interested in the last value for each day (the offset there is because I messed up setting the timezone while a preparing a container collecting the data, so part of the entries was recorded with a wrong timezone).
If I comment out the last line to get daily results, the current month looks like this:
Time | Power_PV_Generation_Today |
---|---|
2023-01-04 23:59:00 | 5.12 |
2023-01-05 23:59:00 | 2.95 |
2023-01-06 23:59:00 | 4.12 |
2023-01-07 23:59:00 | 5.74 |
2023-01-08 23:59:00 | 9 |
2023-01-09 23:59:00 | 2.15 |
2023-01-10 23:59:00 | 2.70 |
2023-01-11 23:59:00 | 8.47 |
2023-01-12 23:59:00 | 12.4 |
2023-01-13 15:51:51 | 3.13 |
I was expecting it to be summed up to 74.33, while the actual record of the full query for the current month is:
Time | Power_PV_Generation_Today |
---|---|
2023-01-13 15:54:27 | 71.2 |
Looks like the last value from the first aggregateWindow is disregarded for some reason.
Is there a way to include the record for the current day in the current month sum?
I've tried rephrasing the query in the following way:
from(bucket: "home")
|> range(start: -1y)
|> filter(fn: (r) =>
r._measurement == "inverter" and
(r._field == "Power_PV_Generation_Today")
)
|> aggregateWindow(every: 1d, offset: -1h1m, fn: last, createEmpty: false)
//|> aggregateWindow(every: 1mo, fn: sum, createEmpty: true)
|> window(every: 1mo)
|> sum()
|> duplicate(column: "_stop", as: "_time")
|> window(every: inf)
but the result was identical.