I am not sure but packing the the respective nodes into flow
array as mentioned in the Documentation for node-red v2.2 doesn't work when packaging the subflow as a module.
JSON Generated during Export
The documentation Packaging a Subflow as a module : Node-RED suggests that the Exported JSON takes the form of
[
{ "id": "Node 1", ... },
{ "id": "Node 2", ... },
...
{ "id": "Node n", ... },
{ "id": "Subflow Definition Node", ... },
{ "id": "Subflow Instance Node", ... }
]
For version 2.2.2 this is quite the contrary since the structure is generally
[
{
"id": "f40ab2fe576b55f7",
"type": "subflow",
"name": "..",
"info": "..",
"category": "",
"in": [
{
"x": 480,
"y": 140,
"wires": [
{
"id": "f06facfb30103d6c"
}
]
}
],
"out": [
{
"x": 940,
"y": 140,
"wires": [
{
"id": "f06facfb30103d6c",
"port": 0
}
]
}
],
"env": [],
"meta": {},
"color": "#C0DEED",
"icon": "node-red/bridge.svg"
},
{
"id": "f06facfb30103d6c",
"type": "mqtt in",
"z": "f40ab2fe576b55f7",
"name": "Internal MQTT Broker",
"topic": "",
"qos": "2",
"datatype": "auto",
"broker": "b5bc2cca74215822",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 1,
"x": 700,
"y": 140,
"wires": [
[]
]
},
{
"id": "b5bc2cca74215822",
"type": "mqtt-broker",
"z": "f40ab2fe576b55f7",
"name": "Internal MQTT Broker",
"broker": "internal-mqtt-broker",
"port": "1883",
"clientid": "node-red-mqtt-internal-in",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]
Even upon packing the dedicated nodes under flow
array (as mentioned in the documentation) provides errorenous node (mostly under the function
palette.
Tests
- running two instances of
nodered/node-red:2.2.2
with different published ports e.g.1880
and1990
- create a simple subflow with MQTT In and export the subflow JSON to the clipboard.
- Paste the same JSON into the other instance of Node-Red and the node is available readily without having to change the export values