How to get duration of high levels?


#1

Hi,

I have a door sensor which logs 0 (for closed) and 1 (for open) into an influxDB.

Now I need help to create a query that shows the duration if the door is open(in seconds).

e.g.

2018-01-11 18:20:00 0
2018-01-11 18:20:05 1
2018-01-11 18:20:22 0
2018-01-11 18:20:35 1
2018-01-11 18:20:48 0

Now the result should be:
17
13

17: The duration between 1 (on) at 18:20:05 and 0 (off) at 18:20:22
13: The duration between 1 (on) at 18:20:35 and 0 (off) at 18:20:48

So it should output how long the door was open

Thanks for any help…