LINK call broken?

Hello
I set up my flow using link call node, but it doesnt work, and i am constantly getting error msg.

image

Here is my setup. Where is the problem?

UPDATE:
I think the problem will be with the function..but i dont know why???

This is the function

if (msg.payload === true) {
    msg = {
        "ui_update": {
            "icon": "mdi-lightbulb-on-10",
            "iconColor":"black",
            "buttonColor":"yellow"
        },
        "payload":true,
        "deviceid":msg.deviceid,

    };

} else {
   
    msg = {
        "ui_update": {
            "icon": "mdi-lightbulb-outline",
            "iconColor": "black",
            "buttonColor": "grey"
        },
        "payload": false,
        "deviceid": msg.deviceid,
    };

}

You are generating a brand new msg in your function and therefore discarding the important data that tells the link-call and link-out to route the msg.

instead of setting msg = { ... } , just update the properties of the incoming e.g. msg.payload = ... so that the important stuff required by the link-call is left in tact.

if (msg.payload === true) {
    
    msg.ui_update.icon = "mdi-lightbulb-on-10";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "yellow";
    msg.payload = true;
    msg.deviceid = msg.deviceid;
     

} else {
   

    msg.ui_update.icon = "mdi-lightbulb-outline";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "grey";
    msg.payload = false;
    msg.deviceid = msg.deviceid;

}

return msg;

I tried this one..
But now the Dashboard can not update the button..

image

As the message says, it cannot update something that is undefined. i.e. the things JUST BEFORE .icon - so make it "something" before you try to populate it.

if (msg.payload === true) {
    
    msg.ui_update = {}
    msg.ui_update.icon = "mdi-lightbulb-on-10";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "yellow";
    msg.payload = true;
    msg.deviceid = msg.deviceid;
     

} else {
   
    msg.ui_update = {}
    msg.ui_update.icon = "mdi-lightbulb-outline";
    msg.ui_update.iconColor = "black";
    msg.ui_update.buttonColor = "grey";
    msg.payload = false;
    msg.deviceid = msg.deviceid;

}

return msg;

NOTE: this is far easier in a change node.

Thank you for the help, and the suggestions. It works now

With change node i would need to use another switch node, to differenciate true and false incoming payload, so thats why i thought i can do it in one place.

Of course you can, but you lose the essence of what a visual flow designer is!

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