# How do I dynamically enable or disable config nodes?

**URL:** <https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648>\
**Category:** General\
**Created:** [9 June 2022 01:32 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648 "2022-06-09T01:32:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [9 June 2022 01:32 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/1 "2022-06-09T01:32:47Z")

</div>

I have edited this message.

So this is my flow

```auto
[{"id":"ce085873429da727","type":"serial out","z":"5166dd2a7e38940b","name":"","serial":"bbc414bb7e1feaec","x":430,"y":340,"wires":[]},{"id":"ee4d246d01114515","type":"inject","z":"5166dd2a7e38940b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":80,"wires":[["d079711f78c1baa8"]]},{"id":"d079711f78c1baa8","type":"function","z":"5166dd2a7e38940b","name":"","func":"msg.payload={ 'fc': 3, \n 'unitid': 3, \n 'address': 0 , \n 'quantity': 3 }; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":140,"wires":[["5db00c229ce0e15c"]]},{"id":"5db00c229ce0e15c","type":"modbus-flex-getter","z":"5166dd2a7e38940b","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"64e234ec8ad4b896","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":290,"y":180,"wires":[["4efbfd818ce4af96"],[]]},{"id":"4efbfd818ce4af96","type":"debug","z":"5166dd2a7e38940b","name":"sensor 3 raw data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":290,"y":240,"wires":[]},{"id":"add795f329a38cb4","type":"inject","z":"5166dd2a7e38940b","name":"\"string\", \" 0x3d\", \" 0x10\", 17","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x68\", \" 0x03\", \" 0x01\", \" 0x00\", \" 0x22\", \" 0xab\", \" 0x04\", \" 0x9b\", \" 0x04\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x48\", \" 0x3d\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x48\", \" 0x3e\", \" 0x4a\", \" 0x3a\", \" 0x4b\", \" 0x3a\", \" 0x4b\", \" 0x3a\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x4b\", \" 0xc0\", \" 0x01\", \" 0x47\", \" 0x3e\", \" 0x48\", \" 0x3d\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x4b\", \" 0xc1\", \" 0x01\", \" 0x4a\", \" 0x3b\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x47\", \" 0x3e\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4a\", \" 0x3b\", \" 0x4d\", \" 0x38\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x47\", \" 0xc4\", \" 0x01\", \" 0x4a\", \" 0xc1\", \" 0x01\", \" 0x47\", \" 0xc5\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x47\", \" 0xc5\", \" 0x01\", \" 0x4a\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x49\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x49\", \" 0xc2\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0x3f\", \" 0x4a\", \" 0x3b\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0xc5\", \" 0x01\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0x86\", \" 0x05\", \" 0xa7\", \" 0x04\", \" 0xa0\", \" 0x04\", \" 0x46\", \" 0x3f\", \" 0x46\", \" 0xc6\", \" 0x01\", \" 0x46\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0x40\", \" 0x45\", \" 0xc6\", \" 0x01\", \" 0x44\", \" 0xc7\", \" 0x01\", \" 0x42\", \" 0xca\", \" 0x01\", \" 0x42\", \" 0xca\", \" 0x01\", \" 0x42\", \" 0x44\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xca\", \" 0x01\", \" 0x41\", \" 0xcd\", \" 0x01\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x47\", \" 0x3e\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0xce\", \" 0x01\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0x48\", \" 0x3d\", \" 0xcf\", \" 0x01\", \" 0x3d\", \" 0x10\", \" 0x16\"]","payloadType":"bin","x":220,"y":320,"wires":[["ce085873429da727","d6572391d59bb2cb"]]},{"id":"d6572391d59bb2cb","type":"debug","z":"5166dd2a7e38940b","name":"17 [\"0x68\", \"0x03\" ,]","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":300,"wires":[]},{"id":"bbc414bb7e1feaec","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":" ,","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"1","bin":"bin","out":"time","addchar":"","responsetimeout":"10000"},{"id":"64e234ec8ad4b896","type":"modbus-client","name":"RS485-1","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":1,"commandDelay":200,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true}]

```

I want to have only one RS485 to usb connecter to control both serial and modbus device right now because 1 converter can have 255 devices connected to it and I only have less then 10 devices that is needed to connected to the RS485.

I need to dynamically connect and disable the config nodes of modbus and serial

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e440a6df3b315c1918465b0a84070838d7d4f37.png)

As when I connect one the other onedon't work/can't connect as the port is being used by the other config node. I use serial to write and modbus to read.

An example of the error I see when I try to to enable my serial node it shows connected but gives me this error as its config node can't work as it says the port is being used when modbus config node is connected thus it can read my sensors data.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/40ca54442816579859190e894234d3de69342f1c.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b2142ff0e67ba48d15216c0c6fa706c863d3e0f1.png)

Also when serial can write data as it config node is connected. Modbus config node can't connect .  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73a84ed77a90aa902b688d59d5cf6b96b307565e.png)

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [9 June 2022 03:56 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/2 "2022-06-09T03:56:53Z")

</div>

i am not sure, may be you could enable or disable dynamically both! for example, only when you are writing, disable modbus node, if you are not writing, so enable modbus node, and disable serial node...

---

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [9 June 2022 04:11 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/3 "2022-06-09T04:11:32Z")

</div>

Great idea I will try disable and enable the config node so the port will be "free" for my other connection.

I will change the title to that

---

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [10 June 2022 00:42 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/4 "2022-06-10T00:42:11Z")

</div>

> [@Enabling or disabling a node](https://discourse.nodered.org/t/enabling-or-disabling-a-node/54891/2):
>
> 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.

It may not be posible for me to dynamiclly enable/disable nodes

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [10 June 2022 01:11 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/5 "2022-06-10T01:11:01Z")

</div>

I think you are overcomplicating things by trying to enable/disable nodes .. it is much easier to put a logical true/false switch in front of the node in question and you are done

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dc8b4c4083b0be425d173df5f9a56118804989f8.png)

---

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [10 June 2022 02:25 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/6 "2022-06-10T02:25:11Z")

</div>

Thanks I will try that.

But the issue above is that I only have one usb port and thus only one config node can connect to it at any given time both my serial and modbus need their config node to be connected to the usb port for the node to work.

I do know a easy fix is to have 2 usb to rs485 converter so I have 2 usb port that both config node can be connected to but the whole point of RS485 is that I can have 1 port to control 255 devices over some distant using wires. I am using less than 255 devices so if I have more than 1 usb to rs485 converter it seems strange.

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [10 June 2022 03:49 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/7 "2022-06-10T03:49:01Z")

</div>

Understood... but enable/disable is just a workaround.

As your issue is with rs485/modbus multi-device management/communication ..you may have to re-post towards RS485/Modbus topic 😉 I'm sure there will be some experts to help you with the root cause

e.g. [here](https://discourse.nodered.org/t/multidroping-on-modbus-rtu-node/57618) or [here](https://discourse.nodered.org/t/modbus-serial-whole-bus-disconnects-when-one-device-drops/48555) or [here](https://discourse.nodered.org/t/multiple-device-data-to-table/63476)

It looks like others have solved the multi-device issues

---

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [10 June 2022 04:12 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/8 "2022-06-10T04:12:28Z")

</div>

ok I have reposted this qn on modbus topic [How do I have diffrent nodes modbus and serial node use the same usb port?](https://discourse.nodered.org/t/how-do-i-have-diffrent-nodes-modbus-and-serial-node-use-the-same-usb-port/63705)

---

<div class="post-metadata">

**Author:** ![SP-Mushrooms](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sp-mushrooms/32/61710_2.png) [@SP-Mushrooms](https://discourse.nodered.org/u/SP-Mushrooms)\
**Post date:** [10 June 2022 06:10 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/9 "2022-06-10T06:10:12Z")

</div>

I look through the links you have sent thanks. I now know how to solve some problems I have before.

But all links you have shown only use modbus node [https://flows.nodered.org/node/node-red-contrib-modbus](https://flows.nodered.org/node/node-red-contrib-modbus).  
Which doesn't solve my problem as I am trying to use [https://flows.nodered.org/node/node-red-node-serialport](https://flows.nodered.org/node/node-red-node-serialport) which as I say again both config node is trying to fight for the same port

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [10 June 2022 06:49 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/10 "2022-06-10T06:49:44Z")

</div>

Sorry, I only worked on rs485/Modbus on industrial solutions. Usually, having several devices on rs485 you have to use he same protocoll to adress em. why would you need to send a raw serial packet onto rs485 .. you should do that with Modbus only.

if my memory is correct, there was a modbus-serial cmd which enabled you to send a serial package via modbus

---

<div class="post-metadata">

**Author:** ![mvr](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mvr](https://discourse.nodered.org/u/mvr)\
**Post date:** [7 July 2022 17:31 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/11 "2022-07-07T17:31:18Z")

</div>

Hello!  
This caught my attention, too. I'm working with _Siemens S7 PLCs_ (with `node-red-contrib-s7`) and I'm trying the following: if the S7 doesn't give any signal (i.e. using the _Trigger_ node), go ahead and deactivate the config node for that PLC. We have so many PLC nodes and config nodes that we don't want to overflow the page with connection/production errors.  
I'm trying to write some code and I will upload it as soon as it makes some sense.

Hope you can 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:** [7 July 2022 18:26 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/12 "2022-07-07T18:26:52Z")

</div>

> [@mvr](#):
>
> we don't want to overflow the page with connection/production errors.

Which page?

---

<div class="post-metadata">

**Author:** ![mvr](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mvr](https://discourse.nodered.org/u/mvr)\
**Post date:** [21 July 2022 07:21 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/13 "2022-07-21T07:21:54Z")

</div>

I see why that can be confusing. For the sake of simplicity I would encourage you to ignore the part you are refering to. I simply want to:

> if the S7 doesn't give any signal (i.e. using the _Trigger_ node), go ahead and deactivate the config node for that PLC.

---

<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:** [19 September 2022 07:22 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/14 "2022-09-19T07:22:42Z")

</div>

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