# How to make a reset function

**URL:** https://discourse.nodered.org/t/how-to-make-a-reset-function/75411
**Category:** General
**Tags:** function-node
**Created:** [19 February 2023 09:23 UTC](https://discourse.nodered.org/t/how-to-make-a-reset-function/75411 "2023-02-19T09:23:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kelvin](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kelvin](https://discourse.nodered.org/u/kelvin)
#### Post date: [19 February 2023 09:23 UTC](https://discourse.nodered.org/t/how-to-make-a-reset-function/75411/1 "2023-02-19T09:23:59Z")

</div>

Hi everyone,

1. On my flow how to make a reset function to reset the hourglass?
2. For my gate node why only will open and will not be close.

thanks

```auto
[{"id":"5828b22c3ad72aa3","type":"tab","label":"Flow 6","disabled":false,"info":"","env":[]},{"id":"994620e4c1c5a9b2","type":"group","z":"5828b22c3ad72aa3","name":"simulated data","style":{"label":true},"nodes":["b704573c4e2d4d47","96d3c8bd2bca401a"],"x":434,"y":279,"w":172,"h":122},{"id":"b704573c4e2d4d47","type":"inject","z":"5828b22c3ad72aa3","g":"994620e4c1c5a9b2","name":"","props":[{"p":"payload1","v":"1","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":530,"y":320,"wires":[["831f143dfbc0c173"]]},{"id":"96d3c8bd2bca401a","type":"inject","z":"5828b22c3ad72aa3","g":"994620e4c1c5a9b2","name":"","props":[{"p":"payload2","v":"0","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":530,"y":360,"wires":[["831f143dfbc0c173"]]},{"id":"0dc1f5c82c08c6cd","type":"gate","z":"5828b22c3ad72aa3","name":"","controlTopic":"control","defaultState":"open","openCmd":"start","closeCmd":"stop","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":1050,"y":340,"wires":[["11af8bb18f7735b3"]]},{"id":"831f143dfbc0c173","type":"function","z":"5828b22c3ad72aa3","name":"","func":"if(msg.payload1 ==1){\nmsg.command = msg.payload \nmsg.command = \"start\"\n}\n\nelse if(msg.payload2 ==0){\n msg.command = msg.payload\n msg.command = \"stop\"\n\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":340,"wires":[["1666cee8e1d94595"]]},{"id":"11af8bb18f7735b3","type":"hourglass","z":"5828b22c3ad72aa3","name":"","persistId":"","humanizeLocale":"","x":1220,"y":340,"wires":[["ae60174541a1f5e8","eb156c1ad4715ccc"]]},{"id":"ae60174541a1f5e8","type":"function","z":"5828b22c3ad72aa3","name":"","func":"var a = msg.elapsed.time.seconds\nvar b = msg.elapsed.time.minutes\nvar c = msg.elapsed.time.hours\na = a/3600;\nb = b/60;\nmsg.payload = (a + b + c)/8;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":440,"wires":[[]]},{"id":"eb156c1ad4715ccc","type":"debug","z":"5828b22c3ad72aa3","name":"debug 22","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"elapsed.time","targetType":"msg","statusVal":"","statusType":"auto","x":1320,"y":240,"wires":[]},{"id":"1666cee8e1d94595","type":"trigger","z":"5828b22c3ad72aa3","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":900,"y":340,"wires":[["0dc1f5c82c08c6cd"]]}]

```

---

<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: [19 February 2023 10:20 UTC](https://discourse.nodered.org/t/how-to-make-a-reset-function/75411/2 "2023-02-19T10:20:31Z")

</div>

Did you read the information on the `Help` tab?

It also doesn't seem like a very friendly/intuitive node. You might want to open an issue on the node's [GitHub page](https://github.com/eschava/node-red-contrib-hourglass/issues)

---

<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: [20 April 2023 10:20 UTC](https://discourse.nodered.org/t/how-to-make-a-reset-function/75411/3 "2023-04-20T10:20:43Z")

</div>

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