Link in node not working when the flow is created with Admin HTTP API

Hi,
I'm using the Admin HTTP API to create new flows automatically. Those flows contain a "link in" node linked to my main flow. But when the flow is created, the link node is not workin even if it's written that it is connected the "link out" node. The communication only work when I deploy the flow again.

Is there anyway to make this communication work without having to deploy the flow manually ?

You will probably need to show actual examples of how you are driving the Admin API and the JSON you are sending.

This is the javascript that I'm using to create the JSON to send to an HTTP REQUEST node :

var id = [];
var idArray = [];
for (var j=0;j<4;j++){
    for (var i=0;i<8;i++) {
        idArray.push(Math.round(0xff*Math.random()).toString(16).padStart(2,'0'));
        id[j] = idArray.join("");
        idArray = [];
    }
}

const object = {
    "id": "91ad451.f6e52b8",
    "label": "Node",
        "nodes": [
        {
            "id": id[0],
            "type": "link in",
            "z": "4d1a38f1fc91f648",
            "name": "Receiver",
            "links": [
                "23c2ad085d6e61db"
            ],
            "x": 1065,
            "y": 820,
            "wires": [
                [
                    id[1]
                ]
            ]
        },
        {
            "id": id[1],
            "type": "ui_text",
            "z": "4d1a38f1fc91f648",
            "group": "f2fc2a1c6529e16e",
            "order": 0,
            "width": 0,
            "height": 0,
            "name": "",
            "label": "text",
            "format": "{{msg.payload}}",
            "layout": "row-spread",
            "className": "",
            "x": 1270,
            "y": 820,
            "wires": []
        },
        {
            "id": id[2],
            "type": "ui_group",
            "name": "Test",
            "tab": "bef57110583eb196",
            "order": 1,
            "disp": false,
            "width": "6",
            "collapse": false,
            "className": ""
        },
        {
            "id": id[3],
            "type": "ui_tab",
            "name": "Home",
            "icon": "dashboard",
            "disabled": false,
            "hidden": false
        }
    ]
}
msg.payload = object;
return msg;

And this create a flow like that :
image

And when I try to send information with the link node I can't receive anything in the new flow. And if i move a node to be able to deploy the changes, then it work.

Which Admin Api are you sending that to?

Based on the format of the JSON, I'm guessing you are passing that to the /flow endpoint to add this as a new flow?

I can see you have a link pre-configured in the link in node - I assume that is an attempt to connect it to an existing link out node you already have?

I think the issue will be that the link out node isn't also being updated to tell it about the new node you want it to connect to.

When you do this in the editor, the editor takes care of updating both the link in and link out node configurations to match. Just importing the new flow containing the link in node won't touch the existing link out node.

I'm using the Admin HTTP API with POST /flow.

Exactly, I have a existing link out node that need to communicate with all the new flows created.

Yes, you're right, when I reload only the flow containing the link out node the communication work.

So is there a solution to reload only this flow without using the editor ?

Maybe you could

  • Pre-link the link out to a link in on a temporary tab
  • note the ID of the temporary TAB and the link-in node
  • generate the /flow with the same IDs to replace the existing temporary flow

I don't think this solution will work if I want to add multiples flows

No, it would not.

Alternatively, then, use MQTT.

Subscribe to the same topic. Your main (static) flow would simply publish to that topic and any subscribers would be notified.

Thank you that's a good idea and it work very well !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.