Duration of sensor ON time in hour_minutes_seconds

Hi, I’m new to grafana and unfortunately couldn’t find any help yet related to my topic. First of all I’m using grafana version 6.6.1 with influxdb version 1.7.9.

I have a sensor that stores the state of the sensor in the Influxdb every minute. The state is either 0 or 1. I already have a graph (see picture) where I can see what the state is over the selected interval. In addition, I want to get the total number of hours and minutes over the interval where the status is 1 and display it in a singlestat panel. Is that possible somehow? I would appreciate some help, as I have no idea how to do this.

This is my query:
SELECT sum(“value”) FROM “state” WHERE (“entity_id” = ‘irrigation_motor’) AND timeFilter GROUP BY time(__interval) fill(previous)

Thanks!

Hi did you find solution for that? I have same query

No, mybe it can not be resolve with default Grafana query …
I used a plugin (natel-discrete-panel) which is helped me somehow … but this is not so good. Its not clear for me why Grafana has no such integration by default .