I am trying to calculate my energy cost with datapoints published to my influxdb. I need to utilize windowPeriod
in order to go back far enough in time. I am currently taking a sum of my energy usage and trying to do arithmetic on it, which if I use hard coded times is no problem. But that doesn't scale at all.
from(bucket: "energydata")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["device_name"] == "Home-14")
|> filter(fn: (r) => r["detailed"] == "False")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> sum(column: "_value")
|> map(fn: (r) => ({r with _value: r._value * 0.13806 / (float(v: int(v: v.windowPeriod)) / 1000000000.0 * 60.0 ) }))
I believe it is when trying to convert the windowPeriod
into something useful that it breaks. As I change my period of review my results are all over the place.