Im not big coder and thats why node red works well for me, i love it !
My question is, i have for example, A Modbus node wired to function node with a few lines of codes, then wired to an Mqtt node.
Is it possible i can group the Modbus and function node together and turn them into one node ?
Thus i only have to wire to the Mqtt node.
Thanks for writing back. The reason i asked the question is because It is being used more than once, and by people not familiar with the software.
Ill explain in more detail the setup i'm after, looking for.
We have integrated a small PLC onto an MC running node red. they are kind of bundled together as one device.
The PLC is programmed in node red using modbus protocol. it is a case of wiring Modbus nodes to Mqtt nodes. The data is then sent to the broker and visualized
The end user is looking for simplicity and most definitely wants to avoid copying pasting code or writing code.
Some of the Modbus addresses require a function block with some java to organize byte order and data and some basic math.
I did think about pre populating a flow with all the nodes pre configured, that way end user has it all ready. Practical but not efficient! Unused activated Modbus nodes will add weight to the Bus.
So i thought if i could group batch nodes together with the relevant function block java code. copy these nodes to a flow out of the way from the main flow page. name that flow, "Backup" inventory".
The end user can then just copy and paste them to his main flow, enter the modbus addresses and wire to the mqtt node.
Each batch would be named somthing like
Analog input
Thermocouple input
Analog Output
Dgital write.
Unfortunately the available Modbus nodes written for node red don't work as seamlessly as one would expect. wiring from a Modbus node directly to a Mqtt node would be a dream, simply doesn't happen.
I am also looking at sourcing some help on maybe writing a node specifically to do this. A lot of big player IOT firms with PLC products have done this in node red to there own proprietary protocol.
Then you could try subflows, but give as you will still need to add the modbus address, in the modbus node, within the subflow I don't think you will gain a lot.
Given the complexities of Modbus, I wouldn't expect to be able to simply wire up a Modbus-IN node to a MQTT-out node without doing some data formatting, or otherwise you are doing the data formatting post MQTT.
One small point, the Node-RED function nodes are written in Javascript not java...