Help needed using flow.serialnumber into command line

Hi There,

I am currenlty using node-red to program routers automatically.

Now I want to set the router-identity to an unique ID which I saved as a string in flow.serialnumber.

But since my knowledge isn't that best I am asking you guys.

I am using this code:

{
    "command": [
        "/system/identity/set",
        "=name=XXXXXXXX"
    ]
}

But on the XXXXXXXX place I need to place my flow.serialnumber string.

How can I do this?

Thanks in advance!

You could do it several ways in a template node, JSONata, function node.

Here is the function version...

var serialnumber = flow.get("serialnumber");
msg.payload = {
    "command": [
        "/system/identity/set",
        "=name=" + serialnumber 
    ]
}
return msg;

NOTE: I have had to assume you want this in msg.payload

1 Like

Great! this worked thanks!

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