I’ve got a bucket of source data called “ha - Tyden 2”. In a task I get the data from this bucket and put it to the destination bucket called “ha - Mesic 3”. The task runs every 3h and produces a “min” aggregation. The task source code:
option task = {name: "Downsampling - 3h", every: 3h}
data = from(bucket: "ha - Tyden 2")
|> range(start: -task.every)
|> filter(fn: (r) => (r["_measurement"] != "state"))
|> filter(fn: (r) => (r["_field"] == "value"))
data
|> filter(fn: (r) => (r["agregace"] == "min"))
|> min()
|> duplicate(as: "_time", column: "_stop")
|> to(bucket: "ha - Mesic 3")
In the source bucket I have 2 recent values of 70,6 which are the minimum. The problem is that the task is not reflecting these two minimal values and produces the destination data without them.
I tried to test everything in the explorer. This is the test code:
from(bucket: "ha - Tyden 2")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kg")
|> filter(fn: (r) => r["entity_id"] == "ble_weight_c8478cd9480e")
|> filter(fn: (r) => r["agregace"] == "min")
|> yield(name: "ha - Tyden 2")
from(bucket: "ha - Tyden 2")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kg")
|> filter(fn: (r) => r["entity_id"] == "ble_weight_c8478cd9480e")
|> filter(fn: (r) => r["agregace"] == "min")
|> aggregateWindow(every: 3h, fn: min, column: "_value", timeSrc: "_stop", timeDst: "_time")
|> yield(name: "Task reproduction")
from(bucket: "ha - Mesic 3")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kg")
|> filter(fn: (r) => r["entity_id"] == "ble_weight_c8478cd9480e")
|> filter(fn: (r) => r["agregace"] == "min")
|> yield(name: "ha - Mesic 3")
The first block simply takes the data form the source bucket without any aggregation.
The second block tries to simulate what the task does and yields it into “Task reproduction”.
The third block simply takes the data form the destination bucket without any aggregation.
The third block doesn’t show those 2 minimal values of 70,6 but the second block (which is just the task reproduction) properly shows the minimum of 70,6.
So I must have some problem lying within the task but I cannot figure out what. Or I badly don’t understand some basics