Insufficient dynamic mqtt documentation?

Node red doc for mqtt in (dynamic) is somewhat lackluster. Trying this for the first time, I see what's presented, but not sure what "broker" is (type?), compared url and port. Also I don't see anywhere to specify client id. Luckily, thanks to amazing community, there are some existing discussions which shed some light. Like this: Dynamic MQTT node's "actions->connect" guidance needed

Wouldn't it be nice to update the documentation to include this info readily available?

I'm also not sure about connect vs subscribe, do I need to do both (first connect, then subscribe?) or choose one of them?

I find dynamic config is much smoother compared to hardcoded values, because it is how "everything" else works (like http for example) and it allows for .env variables to store secrets outside node red.

You should take a read of this great tutorial of MQTT:

to get a handle on the terminology used.

What do you think should be added to the HELP for the MQTT nodes? Show what you think would make the current explanation better. If people agree you could even create a PR to update the help.

1 Like

Broker would be the IP of the broker (should possibly say server as in config title).
But there are many topics on this in the forum, here is one from the nodes maintainer that has many examples Dynamic MQTT LWT birth, Close & Will Property - #2 by Steve-Mcl
I am surprised these examples have not bee added to the node-red library import examples for the node.

1 Like

I want to set the connection credentials in function node. That requires "dynamic settings" to get input. Then the doc says the following:

broker broker
For the "connect" action, this property can override any of the individual broker configuration settings, including:

    broker
    port
    url - overrides broker/port to provide a complete connection url
    username
    password

If this property is set and the broker is already connected an error will be logged unless it has the force property set - in which case it will disconnect from the broker, apply the new settings and reconnect.

What is broker? Where is clientId?

Thanks! Yeah the only official examples I found was the simplified version with hardcoded connection in config node.

Broker is IP of broker? How does that compare to URL then? Cause I normally enter IP into url fields, ref http.

MQTT in gives linting error if not setting a broker config node. I don't want broker config node, as this is set dynamically. Unless broker config node can take dynamic env variables (which as far as I can see, it cannot).

If I add a dummy broker config node, it too gives linting error if not setting server (blank). So I add dummy server/url value to the dummy config node.

Without anywhere to dynamically set client ID, I'm not getting connected.

When setting correct client id to the dummy config node, I get connected. Why is "dynamic mode" not supporting dynamic client id?

URl would be a ip or domain with port, and would override broker and port.
e.g
192.168.1.20:1883

Got it thanks! Now onto client id... :thinking:

Also struggling with getting the auto-connect feature of static config applied to dynamic config. Only way I found so far is to add status node, listen and filter status changes from mqtt-in and then send it to function node before mqtt-in node. A bit too messy and fragile for my liking.

"force" (boolean) arg in broker seems interesting and useful. Is this documented anywhere? I accidentally stumbled upon it in a discussion, so found it by chance. Would be great to have this in the HELP section!

It is mentioned at the bottom of the sidebar help text

If this property is set and the broker is already connected an error will be logged unless it has the force property set - in which case it will disconnect from the broker, apply the new settings and reconnect.

1 Like

Good find! Unfortunately node red hijacks browser ctrl+f to search doc, so I'm struggling a bit to change muscle-memory to use F3 instead.

I assume "dynamic" config can't dynamically set client id?

Asked 6 days ago Can the MQTT ClientID be set dynamically?

1 Like

Thanks, somehow that didn't show up when I made this topic and also failed at finding it when searching. Would be wonderful to have all these "secret" attributes documented in HELP section :star_struck: But for me, I get what I need now with that great community example.

1 Like

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