Hey all,
I know this is a frequently asked question, but I seem to just do not get it right. I want the daily power consumption.
This is what I build so far:
from(bucket: "iobroker")
|> range(start: -1d)
|> filter(fn: (r) => r["_measurement"] == "Wechselrichter.Ertrag.Total.Summe")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: 1d, fn: last, timeSrc:"_start")
|> difference()
Looking sharp as:
But: the value is not correct. When I go into the data source and look at the values it should be 2,7 kWh, not 2,3 kWh.
Anyone with a hint for me whar could be wrong?
Thanks
try timeSrc: "_time"
, not “_start”
infofcc3:
_time
Thanks - this results in “No Data” - Error: column “_time” doesnt exist
grant2
June 14, 2025, 4:05pm
4
What about timeSrc:“_stop”
fgottschalck:
from(bucket: "iobroker")
|> range(start: -1d)
|> filter(fn: (r) => r["_measurement"] == "Wechselrichter.Ertrag.Total.Summe")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: 1d, fn: last, timeSrc:"_start")
|> difference()
Thanks @grant2 - unfortuntately same - wrong - result.
Interestingly: when I am doing the same with monthly values, it calculates correct values.
grant2
June 15, 2025, 3:21pm
6
Did you read thru this thread?
@myozone
difference() returns the difference between subsequent values. You are querying a whole day’s worth of readings, so you need to use the spread() function as previously described. Also, there is a way in Flux to specify yesterday (Grafana too, but let’s focus on Flux).
Something like this should work:
import "experimental/date/boundaries"
day = boundaries.yesterday()
from(bucket: "buckett")
|> range(start: day.start, stop: day.stop)
|> filter(fn: (r) => r["_measurement"] == "kwh…
Thanks again @grant2 - did read this now, but to be honest, do not understand ist. I fiddled around with ChatGPT too but still no exakt data. I think I will go the way to catch a value via Blockly/javascript at midnight, this seems to be easier for a newbie like me.
Thanks again for your help.