# How to activate-deactivate nodes?

**URL:** <https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052>\
**Category:** General\
**Created:** [8 June 2023 12:16 UTC](https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052 "2023-06-08T12:16:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AleksKan](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@AleksKan](https://discourse.nodered.org/u/AleksKan)\
**Post date:** [8 June 2023 12:16 UTC](https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052/1 "2023-06-08T12:16:59Z")

</div>

Hi everyone!  
I made a flow as shown, and I want to make two buttons. One button has to activate Function1 section and deactivate Function2 section. Another button has to do vice versa. Is it possible to do it? Looks like I'm stuck...  
 ![изображение](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d18aafe19b1b722a31b0cb3ec2524a5d6b3ae048.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 June 2023 12:38 UTC](https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052/2 "2023-06-08T12:38:55Z")

</div>

You need a switch node to route messages along one path or the other depending on a context variable set by your buttons.

Or if you sometimes want both functions to execute, two switch nodes and two variables

---

<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:** [8 June 2023 12:41 UTC](https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052/3 "2023-06-08T12:41:03Z")

</div>

Or you can use node-red-contrib-simple-gate to block messages to the innapropriate function when necessary. You can join the button node directly to the gate node.

---

<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:** [7 August 2023 12:41 UTC](https://discourse.nodered.org/t/how-to-activate-deactivate-nodes/79052/4 "2023-08-07T12:41:28Z")

</div>

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