Hi,
I have created an aggregation function that uses a reduce function to count activations (0-1 transitions of a device) per day. This already works nearly as I would like it to. The only thing missing is, that when the day is changed, and the device is already active during change of day, I don’t want to count the activation.
The next missing piece is that when I want to show the graph, I only see a dot for each sum, no line is printed. Is there a way to setup a bar chart? At least a connection between the measurements would be fine.
Here’s the query
from(bucket: "myBucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "heating")
|> filter(fn: (r) => r["_field"] == "Verdichter")
|> window(every: 1d)
|> reduce(
fn: (r, accumulator) => ({
sum: if accumulator.lastval == 0 and r._value == 1 then
accumulator.sum + 1
else accumulator.sum,
lastval: r._value
}),
identity: {sum: 0, lastval: 0.0},
)
|> duplicate(column: "_start", as: "_time")
|> duplicate(column: "sum", as: "_value")
|> yield(name: "_value")
I’m completely new to InfluxDB, so I appreciate your help!
Thank you