# How can I switch an actuator on and off with time delay based on an input value

**URL:** <https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873>\
**Category:** General\
**Created:** [23 March 2023 16:33 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873 "2023-03-23T16:33:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gitsaibot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gitsaibot/32/58008_2.png) [@Gitsaibot](https://discourse.nodered.org/u/Gitsaibot)\
**Post date:** [23 March 2023 16:33 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873/1 "2023-03-23T16:33:01Z")

</div>

Initial situation:

I get a value that changes second by second. If the value is above 100 for 5 minutes, I want to switch on a pump. If it is below 100 for 10 minutes, I want to switch the pump off again.

Are there suitable nodes for this or do I have to realize all this in a javascript function node? And does anyone have an idea how this could be easily implemented.

Thanks in advance for the help!

---

<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:** [23 March 2023 16:55 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873/2 "2023-03-23T16:55:25Z")

</div>

Have a look at the Trigger node. A couple of those might be what you need.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 March 2023 17:52 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873/3 "2023-03-23T17:52:53Z")

</div>

Something like this should work.

```auto
[{"id":"1fa1111cce45aaa0","type":"inject","z":"8be23377afc3327e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":370,"y":580,"wires":[["9700b7809f02ede2"]]},{"id":"9700b7809f02ede2","type":"switch","z":"8be23377afc3327e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"100","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":600,"wires":[["abb14cafece37181"],["33d822fda0aead08"]]},{"id":"80f0c534805d7a2a","type":"inject","z":"8be23377afc3327e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":370,"y":640,"wires":[["9700b7809f02ede2"]]},{"id":"abb14cafece37181","type":"change","z":"8be23377afc3327e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":560,"wires":[["7288e44d8b9a01e4","157d44e41167208e"]]},{"id":"33d822fda0aead08","type":"change","z":"8be23377afc3327e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":640,"wires":[["157d44e41167208e","7288e44d8b9a01e4"]]},{"id":"7288e44d8b9a01e4","type":"trigger","z":"8be23377afc3327e","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"true","bytopic":"all","topic":"topic","outputs":1,"x":890,"y":640,"wires":[["8285b6acad2aeb8a"]]},{"id":"157d44e41167208e","type":"trigger","z":"8be23377afc3327e","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"false","bytopic":"all","topic":"topic","outputs":1,"x":880,"y":560,"wires":[["8285b6acad2aeb8a"]]},{"id":"8285b6acad2aeb8a","type":"rbe","z":"8be23377afc3327e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1050,"y":600,"wires":[["38fe4a9fec87dab6"]]},{"id":"38fe4a9fec87dab6","type":"debug","z":"8be23377afc3327e","name":"debug 250","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":720,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Gitsaibot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gitsaibot/32/58008_2.png) [@Gitsaibot](https://discourse.nodered.org/u/Gitsaibot)\
**Post date:** [23 March 2023 18:22 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873/4 "2023-03-23T18:22:06Z")

</div>

Thanks for the example, now I understand the trigger nodes.

---

<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 April 2023 18:22 UTC](https://discourse.nodered.org/t/how-can-i-switch-an-actuator-on-and-off-with-time-delay-based-on-an-input-value/76873/5 "2023-04-06T18:22:32Z")

</div>

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