# Threshold function or node

**URL:** <https://discourse.nodered.org/t/threshold-function-or-node/78872>\
**Category:** General\
**Tags:** function-node\
**Created:** [1 June 2023 14:54 UTC](https://discourse.nodered.org/t/threshold-function-or-node/78872 "2023-06-01T14:54:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Popolackie](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@Popolackie](https://discourse.nodered.org/u/Popolackie)\
**Post date:** [1 June 2023 14:54 UTC](https://discourse.nodered.org/t/threshold-function-or-node/78872/1 "2023-06-01T14:54:19Z")

</div>

Hi dear forum, I am stuck on a topic concerning whether to use a function or just nodes. I would like to create a threshold with damping as we use it in PLC programming (just because I´m used to it). If there is any easier way please comment. Ok I try to explain what I would like to do: if a value reaches a threshold I would like a time to be startet (damping time). If this time has expired and the threshold is still reached, a message is fired (setpoint). if the has expired and the threshold is nomore reached, do nothing exept reset time. I would suggest something like:  
if (value \>= threshold)  
{  
pause(30s);  
if (value \>= threshold)  
{  
send setpoint  
}  
}

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 June 2023 21:00 UTC](https://discourse.nodered.org/t/threshold-function-or-node/78872/2 "2023-06-01T21:00:37Z")

</div>

Something like this maybe?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0c8e82f91921918b68674bf3d8dbe5f270cc38a1.png)

Click 11 and then within 5 seconds click 7 and no message is sent.  
Click 11 and leave it and the original message is passed on.

```auto
[{"id":"f12e995f99b648f6","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"7","payloadType":"num","x":90,"y":1960,"wires":[["b05c1acd8f3a75c4"]]},{"id":"98d36c5f4eb1c9cf","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":660,"y":1980,"wires":[["44a02c445dc6616b"]]},{"id":"02f8941a9fc9d306","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"11","payloadType":"num","x":90,"y":2040,"wires":[["b05c1acd8f3a75c4"]]},{"id":"34edf617dd1f3e6b","type":"switch","z":"bdd7be38.d3b55","name":">10?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"10","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":1980,"wires":[["98d36c5f4eb1c9cf"],["b27136cd4ae17ec5"]]},{"id":"b27136cd4ae17ec5","type":"change","z":"bdd7be38.d3b55","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":2040,"wires":[["98d36c5f4eb1c9cf"]]},{"id":"44a02c445dc6616b","type":"debug","z":"bdd7be38.d3b55","name":"debug 98","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":1980,"wires":[]},{"id":"b05c1acd8f3a75c4","type":"junction","z":"bdd7be38.d3b55","x":240,"y":1980,"wires":[["34edf617dd1f3e6b"]]}]

```

---

<div class="post-metadata">

**Author:** ![Popolackie](https://avatars.discourse-cdn.com/v4/letter/p/5e9695/32.png) [@Popolackie](https://discourse.nodered.org/u/Popolackie)\
**Post date:** [2 June 2023 06:18 UTC](https://discourse.nodered.org/t/threshold-function-or-node/78872/3 "2023-06-02T06:18:10Z")

</div>

Hi Colin, Thank you very much....a completely different approach for me. Think that should work. I still am thinking to much in other struktures. But it tells me again, that most problems can be solved by using standard nodes. Have a nice weekend.

---

<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:** [1 August 2023 06:18 UTC](https://discourse.nodered.org/t/threshold-function-or-node/78872/4 "2023-08-01T06:18:29Z")

</div>

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