# Use config property of subflow in mqtt-nodes

**URL:** <https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431>\
**Category:** General\
**Tags:** mqtt, subflow\
**Created:** [5 June 2025 11:38 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431 "2025-06-05T11:38:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [5 June 2025 11:38 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/1 "2025-06-05T11:38:22Z")

</div>

Hello,

I have to connect my software to four (or more - in the future) MQTT-Servers a once. All MQTT-Servers are of the same kind. My idea is to create a subflow which contains the [mqtt-in]- and [mqtt-out]-nodes. The subflow has a "serverNr" property. At the subflow input only messagens with correct serverNr are forwarded to the [mqtt-out]-node. At the subflow output all messages from the [mqtt-in]-node are marked with the serverNr.  
My Question is: How do I set different MQTT-configuration nodes for instances of the subflow? I figured out, that it is possible to set a configuration node as subflow-property but I don't unterstand how to use this property in the server property of the [mqtt-in]- and [mqtt-out]-nodes.

Thanks a lot for every useful hint.  
LaLe

---

<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:** [5 June 2025 12:09 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/2 "2025-06-05T12:09:28Z")

</div>

> [@L4RS](#):
>
> I have to connect my software to four (or more - in the future) MQTT-Servers at once.

Can you explain what you mean by MQTT-Servers, and why four of them?  
MQTT has a **broker** rather than a server, and it would be an unusual situation where you need to **publish** or **subscribe** to topics on more than one broker.

The mqtt nodes allow dynamic connect/disconnect, so the subflow can connect to the relevant broker based on your "serverNR" property (do you mean msg.serverNR? )

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 June 2025 12:29 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/3 "2025-06-05T12:29:51Z")

</div>

You can also change the broker config to be owned by the subflow - that way each instance gets their own broker

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

  

> [@L4RS](#):
>
> I figured out, that it is possible to set a configuration node as subflow-property but I don't unterstand how to use this property in the server property of the [mqtt-in]- and [mqtt-out]-nodes.

After you add the config env var in the subflow template, when you edit an MQTT in/out inside the subflow template, the dropdown will have an `[env] xxxx` entry.

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

when you create an instance of the subflow, you can select which broker config to use

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

  

Personally, i just avoid this whole pattern and generate the required brokers so I can drop MQTT nodes wherever I please on the flows without the worry of instantiating multiples or feeding every message to a subflow instance (it just gets too messy for my liking)

---

<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:** [5 June 2025 12:34 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/4 "2025-06-05T12:34:29Z")

</div>

I think this does what you want

```auto
[{"id":"eb57e20faeb27863","type":"subflow","name":"MQTT subflow","info":"","category":"","in":[],"out":[],"env":[{"name":"Broker","type":"mqtt-broker","value":"","ui":{"type":"conf-types"}}],"meta":{},"color":"#DDAA99"},{"id":"4d13d7b6754afeee","type":"mqtt in","z":"eb57e20faeb27863","name":"","topic":"test/topic","qos":"2","datatype":"auto-detect","broker":"${Broker}","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":80,"wires":[[]]},{"id":"45545b463a4e5330","type":"subflow:eb57e20faeb27863","z":"997da33a0beedade","name":"","env":[{"name":"Broker","value":"05a2c22533d7eb1b","type":"conf-type"},{"name":"MQTTBroker","value":"localhost","type":"env"}],"x":420,"y":2480,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [5 June 2025 12:45 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/5 "2025-06-05T12:45:33Z")

</div>

Hello jbudd,  
I far as I understand the regular term is "MQTT broker", NodeRED uses Server instead. This is a NodeRED Forum, so I used the NodeRED convention.  
I want to connect to four of them because I used four propertarian systems, each of them is equipped with an own MQTT Server. I want to build a central status display. I think there is no was to persuade the manufactor to publish on an MQTT server of my choice.

---

<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:** [5 June 2025 12:47 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/6 "2025-06-05T12:47:48Z")

</div>

> [@jbudd](#):
>
> MQTT has a **broker** rather than a server,

Unfortunately the MQTT node's broker selection field is named Server. I suppose you could say it is the IP/hostname of the server running the broker.

---

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [5 June 2025 12:55 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/7 "2025-06-05T12:55:00Z")

</div>

"Broker" is the more functional description of an "MQTT Server", while "Server" is the more technical wording for a system wainting clients to connect to a provided service - here "MQTT Brokerage". Some sort of "Matter of Taste".

---

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [5 June 2025 12:57 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/8 "2025-06-05T12:57:52Z")

</div>

Hello Steve-Mcl,

thank you very much. I think your pictures will show me the way. I will try it tomorrow and give feedback / mark it as solution.

---

<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:** [5 June 2025 13:03 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/9 "2025-06-05T13:03:07Z")

</div>

> [@Colin](#):
>
> Unfortunately the MQTT node's broker selection field is named Server.

Yes it is labelled Server and if you click the Add or Edit buttons it takes you to  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a90fe45a5046eb38279e9c4a2a898badc7713137.png)  
or  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/67e4e1099543f240171ae5966283f508733dfe8b.png)

Unfortunately Node-red ~~is rife with~~ has several such inconsistencies 😐

---

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [10 June 2025 04:33 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/10 "2025-06-10T04:33:39Z")

</div>

Hallo Steve-Mcl, hello everybody,

> [@Steve-Mcl](#):
>
> You can also change the broker config to be owned by the subflow - that way each instance gets their own broker [...]

This approche works for my intention. I like the fact, that mqtt configuration node is capsulated in the subflow instance. On the other hand you are right I have to deal with a lot of linking in and out.

Thanks a lot.  
L4RS

---

<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:** [24 June 2025 04:34 UTC](https://discourse.nodered.org/t/use-config-property-of-subflow-in-mqtt-nodes/97431/11 "2025-06-24T04:34:28Z")

</div>

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