I'm working with InfluxDB v2.1.
I have this task:
option task = {
name: "DOWNSAMPLE APRILIA UTILITIES",
cron: "0 * * * *",
}
from(bucket: "homeassistant-aprilia")
|> range(start: -2h, stop: -1h)
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r.entity_id == "shellyem_c45bbe5fed52_channel_1_energy")
|> aggregateWindow(every: 1h, fn: max, createEmpty: false)
|> difference()
|> to(bucket: "downsample-utility-aprilia", org: "sineverba")
it being executed every hour but... it doesn't write anything in the destination bucket.
I have all success logs but nothing in my destination bucket.
If I launch the task directly in source bucket, I can see the value of my interest.
Other, if I don't omit the "to" value, manually launched from bucket it writes the data.
Why?
At the end, I solved with stop
at now:
option task = {
name: "DOWNSAMPLE APRILIA UTILITIES",
cron: "0 * * * *",
}
option entity_id = "shellyem_c45bbe5fed52_channel_1_energy"
data = from(bucket: "homeassistant-aprilia")
|> range(start: -2h, stop: now())
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r.entity_id == entity_id)
|> aggregateWindow(every: 1h, fn: last, createEmpty: false)
|> difference()
|> to(bucket: "downsample-utilities-aprilia", org: "sineverba")