Calculate total time above value?

I’m looking to make a tile that shows total runtime of generator usage for my power dashboard. I’d like to calculate total time above say 100w. Is it possible to do this? I’ve poked around for a while and don’t see an easy way

Here is the graph I will probably copy to make it

And for reference, here is my power dashboard so far, I’m getting there!

First of all, nice power dashboard.

To calculate the total time above a value, I do not think InfluxQL offers a straightforward way to do this (it might be possible in Flux, but let’s not go there!).

I believe you need to store whether the generator is above 100w or not. This means you would create another query that tabulates a 0 or 1 every second (or whatever time interval makes sense to you), whereby…
0 = the generator is running below 100w
1 = the generator is running at or above 100w

The table might look like this:

> select * from generator_usage where time >= '2018-04-11T21:12:31Z' and time <= '2018-04-11T21:20:10Z'
name: generator_usage_above_100
time                  on
----                 -----
2018-04-11T21:12:31Z  0   
2018-04-11T21:12:32Z  1    
2018-04-11T21:13:37Z  1    
2018-04-11T21:14:38Z  0     

If you integrate like this:

> select integral(on) from generator_usage where time ...

You would get 5 as a result, because your generator has been on for 5 seconds. Integral basically iterates over every second in the dataset and increments its counter.

If you get stuck, the Influx forum might be a place worth asking.