How to use stateChangesOnly()

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

Hello @Erikson,
Can you please share some of your data?

Hi @Anaisdg

,result,table,_time,_start,_stop,SensorId,_measurement,MyLevel
,,0,2022-01-04T01:21:32.749972517Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T01:24:14.051705026Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T01:30:54.375700332Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,0
,,0,2022-01-04T01:31:57.76111273Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T01:33:36.0650061Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T01:40:11.500062982Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T01:54:06.227517383Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T02:11:19.635009545Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,0
,,0,2022-01-04T02:22:45.199428528Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1
,,0,2022-01-04T02:27:20.917940063Z,2022-01-03T16:00:00Z,2022-01-04T16:00:00Z,5FA6,TestSensor,1

I am having the exact same problem myself, when running monitor.stateChanges() I get data back, but when using monitor.stateChangesOnly() nothing shows up.