Can I input host,port,user,pass, topic to subscribe in MQTT node?

can I input host, port, user, pass, topic in MQTT node?

I don't want to add a new MQTT broker because I have a lot of MQTT brokers (one device one broker)

Thank you

Yes, via the broker config screen.

What do you mean by not wanting to add a new broker? When you select that in the MQTT node you are not actually creating a new broker (a broker is software running in a device), you are just configuring access to an existing broker.

When you say you have one broker per device do you mean that you have installed something like mosquitto on each device? There is no need to do that if you don't want to, you can use one cetral broker that all your devices use.

According to this thread, all of the brokers you want to use have to be already set up, but in Dynamic mode you can use msg.action and properties of msg.broker to switch between them.

It does seem a little eccentric to have one mqtt broker per device, akin to having one CNN server per news story.

I don't think that is quite correct, or at least it is not as I understand it. Looking at the example in the post you linked to you can setup what is effectively a dummy broker config and then at run time set it to connect to any broker that you like (via its IP).

Thanks for reply, Sorry for not clear question I have used Thingsboard it create a new broker user for every device I need to control that's why I don't need to add a new MQTT broker

What is a broker user?

Sorry, that still doesn't make any sense to me. Please try and explain, remembering that I know nothing about Thingsboard. I don't know what you mean by adding a new broker.

Thanks Colin, yes it looks like I misunderstood that thread. It has a single "broker" setup with IP 0.0.0.0.

I confess I'm pretty confused about this but I did get it working once https://discourse.nodered.org/t/mqtt-dynamic-connection-with-changing-ip-adress/69299/3.
I can't replicate that now though, nor at the moment can I get @Steve-Mcl's example to work.

Hey @jbudd what is the confution? I will try to help.

Do you mean this > Dynamic MQTT node's "actions->connect" guidance needed - #2 by Steve-Mcl < example doesnt work for you?

It still works for me...
msedge_4OETFHpA9b

Thingsboard has the same IP broker with a different username (one device one username) and a different username can't see another username topic it's completely separate not like normal MQTT that's why I don't need to add a new MQTT broker because in longterm its will have a lot of MQTT broker

The help page for the MQTT In node tells you how to dynamically set the username and password. Did you look at the link that @Steve-Mcl posted that explains how to do it?

Thanks Steve,
Yes your example does work on my test Pi now.
I just had to update a bunch of stuff: RPiOS, Node-red and Mosquitto.

1 Like