Date:

Share:

Complete Node in Node Red – CreatifWerks

Related Articles

In this post I will share, how to use red junction Complete a junction

An entire node can be used to monitor the execution of a specific line of a node.

When the Node Monitor by the Complete node has completed execution, it will forward the msg.payload from the monitored node to the Complete Node.

The user can then use the complete node to start another process.

Let’s build the complete node

Level 1

We will build the node to be tracked by Complete Node.

Drag out an injection node and configure as below

level2

Build the Count and Trigger Node

Drag out the function node and paste the code below inside the function node in the On Message tab area.

There are 2 components. The interval function will continue to count by 1000 (one second)

While the SetTimeOut parameter is set to 5000 (5 seconds) for a timeout. In the SetTimeOut function, it will first clear the Interval, update the node state, update the last node count to the payload.

var count = 0;

// start counting

var interval = setInterval(function() {

count++;

node.status({ text: ‘Count: ‘ + count });

}, 1000); // Count every second

// Activation message after 5 seconds

setTimeout(function() {

// Clear the space

clearInterval(interval);

// Update the node state UI when counting

node.status({ text: ‘Message activated!’, fill: ‘green’, shape: ‘dot’ });

// Send the node count

node.send({ payload: count }); // Send the count as payload

node.done(); // Mark the current node as complete

}, 5000);

return null;

Step 3

Drag out Node Debug, and connect all 3 nodes as detailed below

Step 4

Drag out the complete node, set as below

Step 5

Drag out the function node and paste the code below into the function node in the message tab.

This function node will receive the msg.payload value from the “count and run” function that will be passed to the complete node

var count = msg.payload;

msg.payload = “Count completed: ” + count + ” seconds”;

return message;

Step 6

Drag out the debug node and connect the node as below, run the injection node and watch the result

results

Check out how to declare a global variable in node red

Source

Popular Articles