# Enabling or disabling a node

**URL:** <https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891>\
**Category:** General\
**Created:** [8 December 2021 20:33 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891 "2021-12-08T20:33:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rapidshe](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rapidshe](https://discourse.nodered.org/u/rapidshe)\
**Post date:** [8 December 2021 20:33 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/1 "2021-12-08T20:33:56Z")

</div>

Hello everybody!  
I need to automatically Enabling or disabling the nodes.  
I have found plugins "node-red-contrib-simple-gate" and "traffic node", but this is not what I want.  
I just need to disable and enable some the nodes.  
I found this information ([Nodes : Node-RED](https://nodered.org/docs/user-guide/editor/workspace/nodes#enabling-or-disabling-a-node)) , but I cannot figure out how to use it.  
core:enable-selected-nodes  
core:disable-selected-nodes

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [8 December 2021 20:46 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/2 "2021-12-08T20:46:50Z")

</div>

Hi @rapidshe - welcome to the forum.

You cannot dynamically enable/disable nodes in the runtime without deploy a new flow configuration.

The `core:enable-selected-nodes` actions are used in the editor whilst editing the flows.

---

<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 December 2021 21:32 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/3 "2021-12-08T21:32:10Z")

</div>

> [@rapidshe](#):
>
> I need to automatically Enabling or disabling the nodes.

Why do you need to do that?

---

<div class="post-metadata">

**Author:** ![rapidshe](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rapidshe](https://discourse.nodered.org/u/rapidshe)\
**Post date:** [10 December 2021 17:17 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/4 "2021-12-10T17:17:25Z")

</div>

I am using a plugin node-red-contrib-homekit-bridged.  
This plugin is needed to create devices in a home kit (apple application for a smart home).

I want to be able to dynamically add and remove some devices from it.

This can be done by enabling or disabling nodes. or the whole Flow. and after that, of course, you need to do deploy.

---

<div class="post-metadata">

**Author:** ![rapidshe](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rapidshe](https://discourse.nodered.org/u/rapidshe)\
**Post date:** [10 December 2021 17:18 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/5 "2021-12-10T17:18:05Z")

</div>

thank you for your responses!

---

<div class="post-metadata">

**Author:** ![rapidshe](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rapidshe](https://discourse.nodered.org/u/rapidshe)\
**Post date:** [11 December 2021 06:21 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/6 "2021-12-11T06:21:20Z")

</div>

There is a solution! You can enable and disable the flow! Here is a link to the source: [[Setup Help]: Is there a way to display a message in a NRCHKB node or hide it? · Issue #334 · NRCHKB/node-red-contrib-homekit-bridged · GitHub](https://github.com/NRCHKB/node-red-contrib-homekit-bridged/issues/334#issuecomment-721291246)

Here you just need to insert the ID of the desired flow.

> **Summary**
>
> `[{"id":"15d7457.fcac4bb","type":"subflow","name":"Change Flow Disabled","info":"","category":"","in":[{"x":40,"y":40,"wires":[{"id":"42613114.0e42c"}]}],"out":[{"x":860,"y":40,"wires":[{"id":"bc4c108.66f42f","port":0}]}],"env":[{"name":"flowId","type":"str","value":"PUT_FLOW_ID_HERE","ui":{"icon":"font-awesome/fa-id-card","label":{"en-US":"Flow ID"},"type":"input","opts":{"types":["str"]}}},{"name":"nodeRedUrl","type":"str","value":"http://localhost:1880/flow","ui":{"icon":"font-awesome/fa-chain-broken","label":{"en-US":"Node RED api url"},"type":"input","opts":{"types":["str"]}}}],"color":"#DDAA99"},{"id":"8920ad34.ac04a","type":"http request","z":"15d7457.fcac4bb","name":"Retrieve current flow state","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":200,"y":80,"wires":[["2c17ab5e.baf484","4ae06e4d.49bdf"]]},{"id":"bc4c108.66f42f","type":"http request","z":"15d7457.fcac4bb","name":"Update flow state","method":"PUT","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":80,"wires":[["50c71a03.281e54"]]},{"id":"2c17ab5e.baf484","type":"function","z":"15d7457.fcac4bb","name":"Change flow disabled","func":"switch (flow.get('action')) {\n case true:\n msg.payload.disabled = false\n break;\n case false:\n msg.payload.disabled = true\n break;\n default:\n msg.payload.disabled = !msg.payload.disabled\n break;\n}\n\n\nmsg.url = flow.get('url')\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":80,"wires":[["bc4c108.66f42f"]]},{"id":"4ae06e4d.49bdf","type":"debug","z":"15d7457.fcac4bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":150,"y":120,"wires":[]},{"id":"50c71a03.281e54","type":"debug","z":"15d7457.fcac4bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":120,"wires":[]},{"id":"42613114.0e42c","type":"function","z":"15d7457.fcac4bb","name":"Prepare URL","func":"//action true-enable false-disable else toggle\nflow.set('action', msg.payload)\n\nreturn {\n url: flow.get('url')\n}","outputs":1,"noerr":0,"initialize":"flow.set('url', env.get('nodeRedUrl') + '/' + env.get('flowId'))","finalize":"","x":150,"y":40,"wires":[["8920ad34.ac04a"]]},{"id":"92fa3829.8bf878","type":"inject","z":"e0a1eb30.3f3ea","name":"enable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":350,"y":280,"wires":[["42ec474e.43e4c8"]]},{"id":"42ec474e.43e4c8","type":"subflow:15d7457.fcac4bb","z":"e0a1eb30.3f3ea","name":"","env":[{"name":"flowId","value":"8adfcdfd.a8bc9","type":"str"}],"x":600,"y":280,"wires":[[]]},{"id":"ba661f80.77b37","type":"inject","z":"e0a1eb30.3f3ea","name":"toggle (default)","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":240,"wires":[["42ec474e.43e4c8"]]},{"id":"9803b7c0.d164c8","type":"inject","z":"e0a1eb30.3f3ea","name":"disable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":350,"y":320,"wires":[["42ec474e.43e4c8"]]}]`

---

<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:** [9 February 2022 06:21 UTC](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/7 "2022-02-09T06:21:24Z")

</div>

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