Using elapsed to get the total time a state was active


#1

Hi all

Just getting into influx dB and Grafana

I have a lot of data coming from home assistant to influx dB. As an example of what I want to do My TV has a state sensor, on or off logged in influx dB

How can I aggregate the state data based on timestamp into total time the device was in that state. Ultimately I want to group this by day so I can say yesterday 2 hours of tv was watched

Is this possible in influx dB, and if so can it be graphed in Grafana?