Hi @Anaisdg,
stateChanges works for me, and I want to get the record just state changed.
I use the stateChangesOnly but get empty record
stateChanges :
import “influxdata/influxdb/monitor”
import “influxdata/influxdb/schema”
from(bucket: “Mybucket”)
|> range(start: 2021-12-22T00:00:00Z, stop: 2021-12-22T23:59:59Z)
|> filter(fn: (r) => r["_measurement"] == “Sensor”)
|> filter(fn: (r) => r[“SensorId”] == “sensor0”)
|> rename(columns: {“MyLevel”: “_level”})
|> monitor.stateChanges(fromLevel: “0”, toLevel: “1”)
|> aggregateWindow(every: 1h, fn: count,column: “MyState”, createEmpty: true)
stateChangesOnly :
import “influxdata/influxdb/monitor”
import “influxdata/influxdb/schema”
from(bucket: “Mybucket”)
|> range(start: 2021-12-22T00:00:00Z, stop: 2021-12-22T23:59:59Z)
|> filter(fn: (r) => r["_measurement"] == “Sensor”)
|> filter(fn: (r) => r[“SensorId”] == “sensor0”)
|> rename(columns: {“MyLevel”: “_level”})
|> monitor.stateChangesOnly()
thanks