Hi there,
Starting over with influxdb using V2/flux, and having some trouble recreating the monthly bar graphs I had setup. I’m feeding in kwh data from my energy monitor, and need to sort the data into months. I’m able to generate the graph with the following query, but the values are totally wrong for some reason.
Query:
import “timezone”
option location = timezone.location(name: “America/Los_Angeles”)
from(bucket: “energybucket”)
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “iotawatt”)
|> filter(fn: (r) => r[“sensor”] == “Solar”)
|> filter(fn: (r) => r[“_field”] == “kWh”)
|> aggregateWindow(every: 1mo, fn: sum, createEmpty: true, timeSrc: “_start”)
|> map(fn: (r) => ({ _value:r._value, _time:r._time, _field:“Solar” }))
And here’s the chart I’m getting:
As an example, last month’s solar generated was actually 702Kwh, but the chart’s calculating it at 230kwh. What’s really bizzare to me is that I adapted this query from my monthly chart, and the values there are correct.
The actual cumulative value for solar should be about 1.15Mwh.