# Create a delay to stabilze a switch

**URL:** <https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304>\
**Category:** General\
**Created:** [12 July 2021 10:43 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304 "2021-07-12T10:43:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nightmare1](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@nightmare1](https://discourse.nodered.org/u/nightmare1)\
**Post date:** [12 July 2021 10:43 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304/1 "2021-07-12T10:43:26Z")

</div>

Thanks in advance im just new to Node Red.  
Its hard to give this a title, but what i have is a 4 switches controlled by heartrate.  
but i only want to change the switch once it has been within a range for 5 seconds  
In Home Assistant i was able to do this with a delay but when i use a delay in node red i get delays in the function rather than the state.

 ![hrm](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/96b67e77e021180430f8970b23883be7bfb27f29.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 10:54 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304/2 "2021-07-12T10:54:31Z")

</div>

Maybe something like...

![TttuUP50tg](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/26034c4474fa58ab6507088f1f189b833dcc7cc1.gif)

```auto
[{"id":"02692201b0297f2b","type":"inject","z":"1683bd9a.5e0a02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":1290,"y":1200,"wires":[["63351327eee9e2c6"]]},{"id":"06a20cd953d78df7","type":"inject","z":"1683bd9a.5e0a02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"140","payloadType":"num","x":1290,"y":1280,"wires":[["63351327eee9e2c6"]]},{"id":"29819d5115a9b4e4","type":"inject","z":"1683bd9a.5e0a02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"180","payloadType":"num","x":1290,"y":1320,"wires":[["63351327eee9e2c6"]]},{"id":"780620e45c6c7191","type":"trigger","z":"1683bd9a.5e0a02","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":1260,"wires":[["12fd30e396a846a6"]]},{"id":"63351327eee9e2c6","type":"switch","z":"1683bd9a.5e0a02","name":"between 120 ~ 160?","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"110","vt":"num","v2":"170","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1500,"y":1260,"wires":[["780620e45c6c7191"],["f8b4e435485bafc6"]]},{"id":"c1618f6dd36d6daf","type":"inject","z":"1683bd9a.5e0a02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"130","payloadType":"num","x":1290,"y":1240,"wires":[["63351327eee9e2c6"]]},{"id":"f8b4e435485bafc6","type":"change","z":"1683bd9a.5e0a02","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1320,"wires":[["780620e45c6c7191"]]},{"id":"12fd30e396a846a6","type":"debug","z":"1683bd9a.5e0a02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1920,"y":1260,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![nightmare1](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@nightmare1](https://discourse.nodered.org/u/nightmare1)\
**Post date:** [12 July 2021 15:44 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304/3 "2021-07-12T15:44:04Z")

</div>

thanks for the reply, your answer looks intersting , but i havent a clue on how to introduce it as i have 5 outputs from the switch

---

<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:** [12 July 2021 15:58 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304/4 "2021-07-12T15:58:02Z")

</div>

The simple way is to replicate the flow four times for your four ranges.

---

<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:** [10 September 2021 15:58 UTC](https://discourse.nodered.org/t/create-a-delay-to-stabilze-a-switch/48304/5 "2021-09-10T15:58:57Z")

</div>

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