Function Nodes

Estimated reading time: 13 minutes

Function nodes carry out specific functions, as listed below. These function blocks generally are connected to the input nodes and pass values to the output nodes.


Function Node

The Function node is a generic node that can be programmed using standard JavaScript. Complex processing can be done on-the-fly on the input messages and can generate one or more output messages.

Function Node
[
    {
        "id": "ea431baa.b2d16",
        "type": "tab",
        "label": "Flow 1"
    },
    {
        "id": "d5d954d6.cbcd28",
        "type": "function",
        "z": "ea431baa.b2d16",
        "name": "",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 573.5,
        "y": 216.39999389648438,
        "wires": [
            []
        ]
    }
]


Template Node

The Template node takes values from input messages that contain value pairs and inserts the values into the template. This node is very useful when constructing messages, configuration files, HTML, etc. This node is configured with a template of great complexity.

Template Node
[
    {
        "id": "b19c3d2c.042bb",
        "type": "template",
        "z": "ea431baa.b2d16",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "This is the payload:  !",
        "x": 526.5,
        "y": 222.39999389648438,
        "wires": [
            []
        ]
    }
]


Delay Node

The Delay node, as the name suggests, is a generic node that is used to delay messages for a particular time or a random time. It can also be used to change the frequency of the message, for example, 20 messages per second.

Delay Node
[
    {
        "id": "e0b94406.371b18",
        "type": "delay",
        "z": "ea431baa.b2d16",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 478.5,
        "y": 202.39999389648438,
        "wires": [
            []
        ]
    }
]


Trigger Node

The Trigger node is used to create two output messages that are separated by a time interval, which can be configured whenever an input message is received. This node also can act as a watchdog timer.

Trigger Node
[
    {
        "id": "6329df20.45469",
        "type": "trigger",
        "z": "ea431baa.b2d16",
        "op1": "1",
        "op2": "0",
        "op1type": "val",
        "op2type": "val",
        "duration": "250",
        "extend": "false",
        "units": "ms",
        "reset": "",
        "name": "",
        "x": 521.5,
        "y": 204.39999389648438,
        "wires": [
            []
        ]
    }
]


Comment Node

The Comment node, as the name suggests, is a simple comment that can be configured with a title and a body.

Comment Node
[
    {
        "id": "32a71015.b1604",
        "type": "comment",
        "z": "ea431baa.b2d16",
        "name": "",
        "info": "",
        "x": 504.5,
        "y": 190.40000915527344,
        "wires": []
    }
]


HTTP Node

The HTTP node is an HTTP request node. It is used to create and send HTTP requests to a particular URL. GET, PUT, POST, and DELETE methods can be configured from the UI or can be programmed.

HTTP Node
[
    {
        "id": "f8f94a2f.129948",
        "type": "HTTP request",
        "z": "ea431baa.b2d16",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "url": "",
        "x": 586.5,
        "y": 190.40000915527344,
        "wires": [
            []
        ]
    }
]


TCP Node

The TCP node is a TCP request node. It sends the message payload (msg.payload) to a server on a specified TCP port awaiting a response from the server. It can be programmed to wait for data, wait for a particular character, or it can return immediately.

TCP Node
[
    {
        "id": "9eddbbb9.110458",
        "type": "tcp request",
        "z": "ea431baa.b2d16",
        "server": "",
        "port": "",
        "out": "time",
        "splitc": "0",
        "name": "",
        "x": 561.5,
        "y": 215.39999389648438,
        "wires": [
            []
        ]
    }
]


Switch Node

The Switch node is used to route messages based on their properties. The properties can be changed using the UI and various logic can be applied, such as greater than, less than, equal to. Many more comparisons can be applied to the message property.

Switch Node
[
    {
        "id": "79ef8764.2164f8",
        "type": "switch",
        "z": "ea431baa.b2d16",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": ""
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 514.5,
        "y": 220.39999389648438,
        "wires": [
            []
        ]
    }
]


Change Node

The Change node is used to change, delete, or set the properties of incoming messages. Complex changes can be applied using various configurable rules. It also can be used to search and replace in the msg.payload.

Change Node
[
    {
        "id": "13a689b1.f2a8a6",
        "type": "change",
        "z": "ea431baa.b2d16",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 454.5,
        "y": 224.39999389648438,
        "wires": [
            []
        ]
    }
]


Range Node

The Range node is used to scale. It maps the input messages to the new output message. It is used to bound or convert the input value ranges. Example where bounding the value ranges would be relevent include: temperature, pressure, etc. It is undefined for non-numeric data. 

Range Node
[
    {
        "id": "fd0954ec.a9a618",
        "type": "range",
        "z": "ea431baa.b2d16",
        "minin": "",
        "maxin": "",
        "minout": "",
        "maxout": "",
        "action": "scale",
        "round": false,
        "name": "",
        "x": 521.5,
        "y": 208.39999389648438,
        "wires": [
            []
        ]
    }
]


CSV Node

The CSV node is used to convert data from or to a comma-separated-values file (.csv). If the input is a string, the output is a JavaScript object. If the input is a JavaScript object, the output is a csv string.

CSV Node
[
    {
        "id": "5cd54d16.926404",
        "type": "csv",
        "z": "ea431baa.b2d16",
        "name": "",
        "sep": ",",
        "hdrin": "",
        "hdrout": "",
        "multi": "one",
        "ret": "\\n",
        "temp": "",
        "x": 529.5,
        "y": 212.39999389648438,
        "wires": [
            []
        ]
    }
]


HTML Node

A configurable CSS selector syntax is used to extract elements from an HTML document in msg.payload. It is used to parse the HTML and return an array of elements that match.

HTML Node
[
    {
        "id": "e13db0f9.8792f",
        "type": "html",
        "z": "ea431baa.b2d16",
        "name": "",
        "tag": "",
        "ret": "html",
        "as": "single",
        "x": 584.5,
        "y": 206.39999389648438,
        "wires": [
            []
        ]
    }
]


JSON Node

The JSON node is used to convert to and from a JSON object. If the input is a JSON schema, the output is a JavaScript object. If the input is a JavaScript object, then the output is a JSON schema.

JSON Node
[
    {
        "id": "16beb150.56a9ef",
        "type": "json",
        "z": "ea431baa.b2d16",
        "name": "",
        "x": 465.5,
        "y": 215.39999389648438,
        "wires": [
            []
        ]
    }
]


XML Node

The XML node is used to convert from and to xml format. If the input is XML string, then the output is JavaScript object. If the input is JavaScript object, then the output is XML string.

XML Node
[
    {
        "id": "f31c1482.d13b98",
        "type": "xml",
        "z": "ea431baa.b2d16",
        "name": "",
        "attr": "",
        "chr": "",
        "x": 489.5,
        "y": 238.39999389648438,
        "wires": [
            []
        ]
    }
]


RBE Node

RBE stands for Report by Exception Node. This node generates a message when two successive inputs are different from the previous current input.  If the input is the same and changes by a large amount (only for numbers), then this node also generates a message.

RBE Node
[
    {
        "id": "be21599.b3321a8",
        "type": "rbe",
        "z": "ea431baa.b2d16",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "x": 557.5,
        "y": 234.39999389648438,
        "wires": [
            []
        ]
    }
]