Hi all!
I have a water counter that sends the total amount of liters (since it was installed) to InfluxDB, so I can see an always rising graph.
I wanted to see the water consumption per minute and…ChatGPT gave me this code
from(bucket: "HomeAutomation")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Watering")
|> filter(fn: (r) => r["_field"] == "water_counter")
|> difference(columns: ["_value"])
|> aggregateWindow(every: 1m, fn: sum, createEmpty: false)
|> fill(column: "_value", value: 0.0)
that seems about right, except that when there is no consumption the line stays at 1 instead of 0.
Why?
Thanks!