NodeRed

Function node - Rückgabewert

// Message passthorugh, normal return
return msg;
// Will stop flow at this point and not pass anything to next node
return null;
// Send array of messages to single output
arr = new Array(10);
return [arr];
return [[msg1, msg2, msg3]];
// Send msg1 to output 1, msg2 to output 2, msg3 to output 3
return [msg1, msg2, msg3];
// Send msg only to second output (of 4)
return [null, msg, null, null];
// Send 2 messages to first output, none to second, one to third
return [[msg1, msg2], null, msg3];

Context

Daten lesen und speichern. Doku: Writing Functions : Node-RED (nodered.org)

let data = context.get("key")
context.set("key", "value");
let data = flow.get("key");
flow.set("key", "value");
let data = global.get("key");
global.set("key", "value");
// get/set multiple (NodeRED 0.19+)
var values = flow.get(["count", "colour", "temperature"]);
// values[0] is the 'count' value
// values[1] is the 'colour' value
// values[2] is the 'temperature' value
flow.set(["count", "colour", "temperature"], [123, "red", "12.5"]);

Node Status

Doku: Node status : Node-RED (nodered.org)

node.status({fill:"red",shape:"ring",text:"disconnected"});
node.status({fill:"green",shape:"dot",text:"connected"});
node.status({text:"Just text status"});
node.status({});   // to clear the status
// The `shape` property can be: `ring` or `dot`.
// The `fill` property can be: `red`, `green`, `yellow`, `blue` or `grey`

// Example:
this.status({fill:"red",shape:"ring",text:"disconnected"});
this.status({fill:"green",shape:"dot",text:"connected"});

Pasted image 20240621141018.png

URL Parameter

TODO
{{{field of msg object}}}

Working with messages : Node-RED (nodered.org)