Creating a table of time periods of states

I hope the topic title makes sense. Basically, I am feeding my Thermostat’s data into InfluxDB, and obviously using Grafana as a frontend. My thermostat has three states: heating, cooling, and idle. I’d like to make a table where each row is one of the states, with the value being the amount of total time the thermostat spent in each state.

The best I’ve been able to do is get a count of each state, but I don’t know of a good way to transform that into a time range. Ideally it would say something like “Heating - 45 mins”, “Idle - 350 mins”, etc.

I would just do some math to divide it by the polling interval, but the interval doesn’t seem to be consistent:

Hi,

I think you need to solve this kind of problem in the influx db query. I’m not sure though that influx db support that kind of query you’re asking for. Would recommend to have a look/ask a question on the influx db community site.

Marcus