# Pause incoming payload with function and switch node

**URL:** <https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370>\
**Category:** General\
**Created:** [1 December 2018 10:54 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370 "2018-12-01T10:54:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevThePhoenix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/devthephoenix/32/4153_2.png) [@DevThePhoenix](https://discourse.nodered.org/u/DevThePhoenix)\
**Post date:** [1 December 2018 10:54 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/1 "2018-12-01T10:54:38Z")

</div>

i want to Pause a payload coming from mqtt with a switch (Off mode), and want to continue payload coming from mqtt with switch (On mode)

---

<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 December 2018 11:20 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/2 "2018-12-01T11:20:58Z")

</div>

Do you mean you want just to filter out values from mqtt while the switch is off, or do you mean you want to queue them up and then release them all when the switch goes on?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 December 2018 15:25 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/3 "2018-12-01T15:25:17Z")

</div>

Assuming you are happy to just drop any incoming messages while paused. Simply use a global or flow variable set to true/false and add a test in a function node or use a switch node.

If using a function node, don't forget to move the `return msg` default statement to inside the test so that the default is that nothing is passed.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [1 December 2018 20:08 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/4 "2018-12-01T20:08:55Z")

</div>

@DevThePhoenix You might take a look at the [gate](https://flows.nodered.org/node/node-red-contrib-simple-gate) and [q-gate](https://flows.nodered.org/node/node-red-contrib-queue-gate) nodes. They were designed for this sort of thing.

---

<div class="post-metadata">

**Author:** ![DevThePhoenix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/devthephoenix/32/4153_2.png) [@DevThePhoenix](https://discourse.nodered.org/u/DevThePhoenix)\
**Post date:** [2 December 2018 06:18 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/5 "2018-12-02T06:18:16Z")

</div>

yes and it is already done, yesterday night. thanks for the replying my dear tech family.

---

<div class="post-metadata">

**Author:** ![DevThePhoenix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/devthephoenix/32/4153_2.png) [@DevThePhoenix](https://discourse.nodered.org/u/DevThePhoenix)\
**Post date:** [2 December 2018 06:21 UTC](https://discourse.nodered.org/t/pause-incoming-payload-with-function-and-switch-node/5370/6 "2018-12-02T06:21:58Z")

</div>

so thank you drmibell it was a great node just came to know this thanks a lot it solves a lot of problems.
