It would be a useful but niche shortcut for sure. I don't think many people would be using multiple instances in this way?
And of course, is is "just" a shortcut since it doesn't take a lot more to do this with existing nodes - and not just using MQTT but also Websockets, HTTP, TCP, UDP and even Unix sockets.
Well, it is a fairly standard API approach. MQTT not really fully suited because of its lightweight nature. Full fat Message Queue services have response capabilities built in. I would say that a direct TCP connection would possibly be better.
You can feed the mqtt node and whatever else you need to use it with into a Join node, so both are available.
Can you give an example of where you can't easily see how to use MQTT?
Well the one I'm working on now wants to access the last 6 cheerlight colours
These are available as a global variable on another instance, so instead re-generating it in this flow, I decided to send it to my local broker on a topic called nr/globals/lastSixColours and then my 1st flow in this instance just converts all messages to that topic to globals
To eliminate the global variable, using that MQTT topic instead, I would feed the MQTT value and the payload to be checked into a Join node and change the Switch to test the property msg.payload.["nr/globals/lastSixColours"] Contains msg.payload.colour_topic where colour_topic is the topic of the message containing the current colour.
Do you also need to pass colours back to the original system to be added to the list?
I wrote a thing a long time ago (before Node-RED ) to do request-response using MQTT.
As someone pointed out, you publish your data points retained, so they can be retrieved immediately they are requested.
You connect to a broker, subscribe to the topic, receive the retained message, disconnect.
Rather like an HTTP request node, but for MQTT.
I wonder if you could do this with the fancy new "live" MQTT node that came into a recent NR build?