Hello everybody,
I am using the Kapacitor to get the duration of a state with the node StateDurationNode.
For example the input raw data data is:
| timestamp [s] | value [boolean] |
|---|---|
| 0 | FALSE |
| 1 | TRUE |
| 2 | TRUE |
| 3 | TRUE |
| 4 | TRUE |
| 5 | FALSE |
| 6 | FALSE |
The expected result is:
| timestamp [s] | value [s] |
|---|---|
| 1 | 3 |
The current result is:
| timestamp [s] | value [s] |
|---|---|
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
Source code:
stream
|from()
.measurement('data')
|stateDuration(lambda: "state" == TRUE)
.unit(1s)
.quiet()
.as('durations')
|httpOut('duration')
|influxDBOut()
.database('test')
.measurement('durations')
