# Stop and reset countdown clock instead of restart

**URL:** https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468
**Category:** General
**Created:** [21 September 2023 06:31 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468 "2023-09-21T06:31:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Observatory\_Gromme](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Observatory\_Gromme](https://discourse.nodered.org/u/Observatory_Gromme)
#### Post date: [21 September 2023 06:31 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/1 "2023-09-21T06:31:50Z")

</div>

Dear,

I have installed an emergency close system with a 10 minute interval with option to stop / reset.  
For visual / dashboard inspection, i have setup a "donut shaped" gauge countdown.

Problem:  
Clicking ABORT will stop the (separated) process, but only resets the dashboard countdown, not stopping it.  
How to stop / reset it?

Maybe i have overlooked, or you have other solutions. I have indeed set it up that the actual emergency close is working side by side with the countdown clock. The countdown clock is just for visual inspection.

Thank you.

 ![Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef9da796ecbb78412d58e9e5f7e8c3c6e4057fd8.jpeg)

[COUNTDOWN.json](https://discourse.nodered.org/uploads/short-url/kenFiHnIWnd6SvHop2DhOhx3TPL.json) (9.5 KB)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [21 September 2023 06:42 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/2 "2023-09-21T06:42:25Z")

</div>

Hi @Observatory_Gromme

Suggestion:

brake the part/s down that are REALLY needed and make a test flow.

Try to NOT use DASHBOARD nodes - I'll get to that later.

Then with `inject` nodes for input and `debug` nodes for output make a small version of what you want to do.

Why you shouldn't use DASHBOARD nodes?  
Well, they are nice, but if they aren't CRUCIAL to the workings: they are mere _decorations_ to the problem, and don't really make any difference.

**You have two `MQTT` nodes in that flow**  
That too is a problem.  
_I_ don't have access to _your_ MQTT messages.  
Don't include them. They don't help.

delete the two MQTT nodes, the `gauge` and `button` node.  
Replace the `button` with an `inject` (and configure it to send what is sent by the `button` node.  
Replace the `gauge` node with a `debug` and repost the flow.  
There is another light green node I see on the right I can see just after (to the right of the `function` node.) Again: Unless crucial to the flow's working: Don't include it.

---

<div class="post-metadata">

### Author: ![Observatory\_Gromme](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Observatory\_Gromme](https://discourse.nodered.org/u/Observatory_Gromme)
#### Post date: [21 September 2023 07:51 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/3 "2023-09-21T07:51:36Z")

</div>

Dear,

The part that is really needed, is actually working. For a year or so now.  
Just for my information i would like to have that countdown clock couting down ( also works )  
but when i press abort, the clock just resets and start counting down again.

That i want to happen.

The error closing goes behind dashboard and is not dashboard related. I will input debug messages this evening. I will let you know.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [21 September 2023 07:53 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/4 "2023-09-21T07:53:20Z")

</div>

Ok, good to hear.

But as I didn't download/import the flow I don't know what nodes are used.

why not just name the node you are using as the countdown timer?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [21 September 2023 15:08 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/5 "2023-09-21T15:08:05Z")

</div>

> [@Observatory\_Gromme](#):
>
> Clicking ABORT will stop the (separated) process, but only resets the dashboard countdown, not stopping it.  
> How to stop / reset it?

If you send  
`{ "payload": "cancel", "timeout": 0 }`  
to the node, it will stop the timer but will set the counter to `-1` (I think it should be `0`).

If you want the counter to go to 0 you have a couple options:

1. open an issue at the node's GitHub issues and ask the author to make the change (explaining what you think it should be)
2. edit the code yourself (`.node-red/node_module/node-red-contrib-mytimeout/mytimeout.js`) and change all the -1's to 0 (there are 9 locations. Note: if you update the node, you. will have to make the changes again)
3. Do it the way I got around it in my [Coffee Pot Timer](https://discourse.nodered.org/t/coffee-pot-timer/4743) project. What I did was to add a text node and send the time to text node and overlayed that over the mytimeout display

![Sep-21-2023 11-06-20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2cb41fe61190ca141acee05091ffa88db21a8c5.gif)

---

<div class="post-metadata">

### Author: ![Observatory\_Gromme](https://avatars.discourse-cdn.com/v4/letter/o/a587f6/32.png) [@Observatory\_Gromme](https://discourse.nodered.org/u/Observatory_Gromme)
#### Post date: [21 September 2023 20:18 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/6 "2023-09-21T20:18:23Z")

</div>

Well thank you!

> If you send  
> `{ "payload": "cancel", "timeout": 0 }`

That did the trick! Agree, timer stops then at -1, but i can live with that :).

---

<div class="post-metadata">

### Author: ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)
#### Post date: [21 September 2023 20:33 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/7 "2023-09-21T20:33:35Z")

</div>

Dang I missed all the fun! I think this is my mytimeout (I'm the author). I have a pause in the works but I haven't had time to post it (or fully test it). It's in one of my branches (pause 3.2.3 I think). At the moment I'm in the middle of moving my elderly Mom and my system crashed when upgrading to Bookworm. It's recoverable I need a new part.

---

<div class="post-metadata">

### Author: ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)
#### Post date: [22 September 2023 18:45 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/8 "2023-09-22T18:45:19Z")

</div>

I shared this with Paul (Zenofmud):

On the subject of -1, not sure that's the correct change. I do think there is one other change that would work but I need to look at the code. I think stop could return 0 but cancel would continue to return -1. Let me alsos ee what over value I return. It's actually the testing part that makes this so complicated. I'll look at the code when I get the new part this weekend. Good news on my part, I used Github properly and all the changes are there so if the system is a loss I have lost the work.

---

<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: [6 October 2023 18:46 UTC](https://discourse.nodered.org/t/stop-and-reset-countdown-clock-instead-of-restart/81468/9 "2023-10-06T18:46:04Z")

</div>

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