# Timer to show how many hours of gas left in generator tank, best way to approach?

**URL:** <https://discourse.nodered.org/t/timer-to-show-how-many-hours-of-gas-left-in-generator-tank-best-way-to-approach/93406>\
**Category:** General\
**Created:** [24 November 2024 18:34 UTC](https://discourse.nodered.org/t/timer-to-show-how-many-hours-of-gas-left-in-generator-tank-best-way-to-approach/93406 "2024-11-24T18:34:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)\
**Post date:** [24 November 2024 18:34 UTC](https://discourse.nodered.org/t/timer-to-show-how-many-hours-of-gas-left-in-generator-tank-best-way-to-approach/93406/1 "2024-11-24T18:34:19Z")

</div>

I have multiple flows that start or stop a generator based on various things.

I have one flow that checks when the generator runs out of gas and then de-energizes the relay so it doesn't try to start. Then when I fill it, I click a dashboard button and its status goes back to filled.

What I would like to do now is to reset a global variable to 6 hours (one tank of gas) when I press that "I filled it" button, and then when a flow starts the generator, have it show a count-down timer so I can visually see how much fuel is left. And have the timer pause when a flow stops the generator.

What is the best way to go about this? Is there a custom node I should download and explore? Or perhaps I should have my generator start and stop functions also start or stop a trigger node? Or perhaps I should have them write to a text file with a timestamp and have another function do the math?

Thanks in advance for any best practice tips.

---

<div class="post-metadata">

**Author:** ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)\
**Post date:** [24 November 2024 21:49 UTC](https://discourse.nodered.org/t/timer-to-show-how-many-hours-of-gas-left-in-generator-tank-best-way-to-approach/93406/2 "2024-11-24T21:49:24Z")

</div>

I just ended up using javascript and .getTime() and doing a bit of math and now I have it all working. Nothing pretty, but it works.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 February 2025 21:49 UTC](https://discourse.nodered.org/t/timer-to-show-how-many-hours-of-gas-left-in-generator-tank-best-way-to-approach/93406/3 "2025-02-22T21:49:42Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
