Communication between Node and Config Node

I want to send one input value of Config Node to some other Node which is using that config node.

Is there any way to have communication between both Node?

Given that you posted this in the development channel I’m guessing this is a node you are writing?

If so nodes that share a config node can share the config behind the scenes.

For example if you define a MQTT-IN node with broker details then you can select that config in a MQTT-OUT node.
But you have to do the selection, there is no way that I know of for a node to auto-configure.

Hi Devbrat,

Perhaps I don't understand your question correctly, but I'm developing some nodes at the moment that share data with their config nodes.

I get a reference to the config node:

node.deviceConfig = RED.nodes.getNode(config.deviceConfig); 

And then my node starts listening for data (in my case 'status') changes of that config node:

node.deviceConfig.addListener("onvif_status", node.listener); 

Bart

2 Likes

Ah, good call.

Funnily enough I was thinking about that as well as I've been working on uibuilder v2. I'd thought at one point that using a config node would open up some other possibilities for additional nodes. In fact, in the end this is one thing that stopped me.

I actually have gone for an API-based approach though instead and that might be another approach here. uibuilder now has (extended in v2) some API end-points that let the front-end admin ui and other nodes and even end-users get to additional information. Such as the list of installed front-end libraries available to uibuilder web pages and the full list of all uibuilder end-points deployed.

API's are trivial to implement from a custom node.

Im also trying to get a message sent between nodes (one Ive written). So far used a global variable that can be read be all nodes at intervals, where you can put a message queue.

MQTT was another way, but you need mosquitto installed so not so easy when it comes to a PC.

An API sounds like the way to go - so nodes can post to a port and all nodes can listen. But how is that done in practice - i.e. all nodes listening to messages from one node, like an MQTT subscribe ?

TBH, that is a terrible idea (reasons I wont go into right now).

Why not simply use wires like every other node does?

MQTT is simple to setup and install. Also there is a node-red node called aedes that is a MQTT broker itself.

In general it isn't - the whole point of Node-RED being that you can see the wires and what information is going where. Nodes can share a config node, typically for things like in/outbound connections like serialports or mqtt etc... but they can be just between a group of nodes if needed - (eg like the dashboard nodes all share the ui_base config node)

2 Likes

You can wire messages into the different odes, but the hope is to have different nodes (specialised to functions) but if one node recieved an incoming message that the others needed to be informed about, they would be - without the Node-RED user needing to. Thats why MQTT is not possible. It needs to work between nodes without breaking depending on what system the nodes are installed on. Im thinking the only solid way is to write a message queue to a global variable, and each node polls it at intervals.

That would be a fairly horrible and error prone approach.

What is wrong with using a link node to distribute the message to other nodes or areas of flow?