Enabling or disabling a node

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) , but I cannot figure out how to use it.
core:enable-selected-nodes
core:disable-selected-nodes

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.

Why do you need to do that?

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.

thank you for your responses!

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

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"]]}]

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