kWh calculation confusion & flux monthly kWh calc

Any have a monthly total flux query for kWh?

Cant even seem to get the same influxQL query to output similar values. :grimacing:

SELECT integral(“value”) / 3600 / 1000 FROM “TotalPower” WHERE time >= now() - 7d and time <= now() GROUP BY time(1d) fill(null) tz(‘EST’)


from(bucket: “iotawatt/autogen”)
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r._measurement == “TotalPower”)
|> aggregateWindow(every: 1d, fn: (column, tables=<-) =>
tables |> integral(unit: 1d), createEmpty: false)
|> map(fn: (r) => ({ r with _value: r._value / 3600.00 / 1000.0 }))
|> keep(columns: [“_time”, “_value”])
|> sort(columns: [“_time”])

If I comment out the map the returned values are.



Now I cant make sense of any of this. Reading what’s from the iotawatt graph+ show only 2 kWh for 2/17 my grafana calculation seems to be more correct reading 53.5 kWh. What am I doing wrong here???

I figured this all out iotawatt meter shows the daily average needs to be multiplied by 24