Hello!
I’m building a power dashboard for my boat and batteries.
Data is stored in an InfluxDB 2.0 bucket on my Rpi, running Grafana.
By using the integral function of flux to return Watt-hours based on a series of reported watts delivered by a shunt - I am able to show the charged or consumed energy in any selected time-span.
This is working perfectly - but now I want it to automatically select range start (and eventually stop) based on the last time power went from consuming(positive) to charging(negative) and vice versa. - I want to yield a total consumed or charged energy value since the start of the current ongoing cycle.
Does anyone have any inputs how to set range start (and stop) based on the change in value?
This is the query I’m using now:
from(bucket: "Boat")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "electrical.batteries.house.power")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> set(key: "_field", value: "House battery")
|> integral(unit: 1h, column: "_value")
|> yield(name: "mean")
1 post - 1 participant