# Dashboard adjustable timer

**URL:** <https://discourse.nodered.org/t/dashboard-adjustable-timer/904>\
**Category:** Dashboard\
**Created:** [19 June 2018 03:22 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904 "2018-06-19T03:22:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![River](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@River](https://discourse.nodered.org/u/River)\
**Post date:** [19 June 2018 03:22 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904/1 "2018-06-19T03:22:09Z")

</div>

I'm looking to making an adjustable timer for a sprinkling system. I'm very new to coding and have found a forum post with a code that looks like it is exactly what i want but just cant get it to work.  
I believe i have everything where they should be and have the numerical topic set to "value" and the button topic "start". I'm sure I'm missing something I just don't know what.

Here is the code:

[{"id":"ce5534a3.3f8b98","type":"function","z":"be10358d.5f3058","name":"","func":"\nvar value = context.get('value') || 60000;\n\nif (msg.topic == "value")\n{\n value = msg.payload \* 60000;\n context.set('value',value); \n}\n\nelse if (msg.topic == "start")\n{\n\nvar timer = setTimeout(function(){msg.payload = "now";node.send([msg,{ payload: "Ende" }]);var countdownstop = context.get('countdown');clearInterval(countdownstop)},value);\ncontext.set('timer',timer); \n\nvar count = value/60000;\n//count = count -1 ;\nmsg.payload=count;\nnode.send([null,msg]);\nvar countdown = setInterval(function() {count=count-1;msg.payload=count; node.send([null,msg]) }, 60000);\ncontext.set('countdown',countdown);\n\n}\n\nelse if (msg.topic == "stop")\n{\nvar timerstop = context.get('timer')\nclearTimeout(timerstop);\n\nvar countdownstop = context.get('countdown')\nclearInterval(countdownstop);\n\n}\n\n\n","outputs":"2","noerr":0,"x":410,"y":220,"wires":[["a70f86ce.c18f58"],["fa7c7eb.15f9d8"]]},{"id":"a70f86ce.c18f58","type":"debug","z":"be10358d.5f3058","name":"","active":true,"console":"false","complete":"payload","x":590,"y":180,"wires":},{"id":"6c4f84d8.656ebc","type":"ui\_button","z":"be10358d.5f3058","name":"","group":"637d8cb3.d53d74","order":0,"width":0,"height":0,"label":"Start","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"start","x":190,"y":200,"wires":[["ce5534a3.3f8b98"]]},{"id":"1f4a748.bcd498c","type":"ui\_numeric","z":"be10358d.5f3058","name":"","label":"Minuten","group":"637d8cb3.d53d74","order":0,"width":0,"height":0,"passthru":true,"topic":"value","format":"{{value}}","min":"1","max":"300","step":1,"x":180,"y":280,"wires":[["ce5534a3.3f8b98"]]},{"id":"8dba67c8.f2a418","type":"ui\_button","z":"be10358d.5f3058","name":"","group":"637d8cb3.d53d74","order":0,"width":0,"height":0,"label":"Stop","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"stop","x":190,"y":240,"wires":[["ce5534a3.3f8b98"]]},{"id":"fa7c7eb.15f9d8","type":"ui\_text","z":"be10358d.5f3058","group":"637d8cb3.d53d74","order":0,"width":0,"height":0,"name":"","label":"Restzeit","format":"{{msg.payload}} Minuten","layout":"row-spread","x":600,"y":240,"wires":},{"id":"637d8cb3.d53d74","type":"ui\_group","z":"","name":"Default","tab":"7fe8c0a9.8eebd","disp":true,"width":"6"},{"id":"7fe8c0a9.8eebd","type":"ui\_tab","z":"","name":"tests"," ![20180618_211752](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/8b03294afadba2ff73d849beeb8a7611e9b56efc.jpg)icon":"dashboard"}]

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [19 June 2018 05:38 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904/2 "2018-06-19T05:38:40Z")

</div>

take a look on this [https://flows.nodered.org/node/node-red-contrib-smartswitch](https://flows.nodered.org/node/node-red-contrib-smartswitch)

> <https://github.com/scottp/node-red-contrib-smartswitch/blob/master/example.json>

If you look on the flows on the forum u will find a lot of sprinkling projects already too.

Regards

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [19 June 2018 13:11 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904/3 "2018-06-19T13:11:39Z")

</div>

Please edit your post to create a “code block” around that flow text – just put a single line with 3 backticks like ````` before **and** after the json text. Without that, we are not able to copy/paste your flow, since discourse modifies the double guotes to be “smart” (sic) quotes…

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [19 June 2018 14:15 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904/4 "2018-06-19T14:15:38Z")

</div>

I’m a big fan of the Big Timer node that I use in a heater control. While the UI appears intimidating, it basically works by sending the target time in seconds to the input:

Function node:  
//This sets the timer to 20 minutes  
//Payload is in seconds  
msg.payload = “timer 1200”;  
return msg;

---

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [19 June 2018 17:38 UTC](https://discourse.nodered.org/t/dashboard-adjustable-timer/904/5 "2018-06-19T17:38:37Z")

</div>

It seems @River tries to implement what's implemented here:

> [@Timer with UI feedback](https://discourse.nodered.org/t/timer-with-ui-feedback/191/7):
>
> Thank you, Craig. Peter replied that’s normal behavior of BigTimer. So, as solution, I just over-passed the BigTimer node, connecting parse\_timeout straight to switch control. All works now, every day slight_smile Code here, maybe helpful for someone. [ { "id": "6491080e.1afc78", "type": "ui\_switch", "z": "669e4b2e.c077d4", "name": "enable\_water", "label": "Enable Watering", "group": "e6e9e9c5.46a0c8", "order": 1, "width":…
