# How to view how long a light has been on in a day

**URL:** <https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643>\
**Category:** General\
**Created:** [December 16, 2020, 5:58am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643 "2020-12-16T05:58:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![iptvcld](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@iptvcld](https://community.grafana.com/u/iptvcld)\
**Post date:** [December 16, 2020, 5:58am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/1 "2020-12-16T05:58:06Z")

</div>

Hello; does anyone have any good grafana dash’s that will allow me to see how long my lights have been left on for the day?

I am trying discrete addin but wondering if there is a better way?

---

<div class="post-metadata">

**Author:** ![naruktubk](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@naruktubk](https://community.grafana.com/u/naruktubk)\
**Post date:** [July 26, 2021, 9:30am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/2 "2021-07-26T09:30:19Z")

</div>

Do you have any solution yet? I Also want to achieve this with an influxdb data source

---

<div class="post-metadata">

**Author:** ![pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@pooh](https://community.grafana.com/u/pooh)\
**Post date:** [July 26, 2021, 9:51am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/3 "2021-07-26T09:51:34Z")

</div>

Are you just looking for a simple number telling you “lights were on for 6  
hours yesterday” etc, or do you want a graph showing you when they were on and  
when they were off throughout the day?

What data do you have in your data store? Is it “the current state of the  
lights”, so every minute (or however often you sample) you get an “on” or an  
“off” value, or do you just get a state change every time they get turned on or  
turned off?

Antony.

---

<div class="post-metadata">

**Author:** ![naruktubk](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@naruktubk](https://community.grafana.com/u/naruktubk)\
**Post date:** [July 26, 2021, 10:30am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/4 "2021-07-26T10:30:33Z")

</div>

I would like to have a bar diagram. Where for each day it’s shown how long the light was on.

My data saves the state of the light by every state change not with a particular sample rate. The data source is influxdb. I tried “elapsed” there, but that did not get the results i wanted

---

<div class="post-metadata">

**Author:** ![coderunway](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@coderunway](https://community.grafana.com/u/coderunway)\
**Post date:** [August 24, 2021, 10:24am UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/5 "2021-08-24T10:24:25Z")

</div>

> [@naruktubk](#):
>
> I tried “elapsed” t

I’m also looking for same solution(HA+InfluxDB+Grafana). Such a common requirement, this should have a more simpler solution. Anyone got lucky generating this ?

---

<div class="post-metadata">

**Author:** ![grant2](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/grant2/32/42281_2.png) [@grant2](https://community.grafana.com/u/grant2)\
**Post date:** [February 12, 2023, 9:59pm UTC](https://community.grafana.com/t/how-to-view-how-long-a-light-has-been-on-in-a-day/40643/6 "2023-02-12T21:59:59Z")

</div>

Over 18 months later and we have a solution. See [here](https://community.influxdata.com/t/count-in-seconds-how-long-a-value-is-1/28554/1).
