Star

ThingsBoard Documentation

Documentation for using ThingsBoard IoT Platform.

Filter Nodes

Filter Nodes are used for Message filtering and routing.

Check Relation Filter Node

image

Checks the relation from the selected entity to originator of the message by type and direction.

image

If relation exists - Message is sent via True chain, otherwise False chain is used.

Message Type Filter Node

image

In the Node configuration, administrator defines set of allowed Message Types for incoming Message. There are predefined Message Types in the system, like Post attributes, Post telemetry, RPC Request, etc. An administrator can also define any Custom Message Types in the node configuration.

image

If incoming Message Type is expected - Message is sent via True chain, otherwise False chain is used.

Message Type Switch Node

image

Route incoming messages by Message Type. If incoming Message has known Message Type then it is sent to the corresponding chain, otherwise, message is sent to Other chain.

If you use Custom Message Types than you can route those messages via Other chain of Message Type Switch Node to the Switch Node or Message Type Filter Node configured with required routing logic.

Originator Type Filter Node

image

In the Node configuration, administrator defines set of allowed Originator Entity types for incoming Message.

image

If incoming Originator Type is expected - Message is sent via True chain, otherwise False chain is used.

Originator Type Switch Node

image

Routes incoming messages by Originator Entity type.

Script Filter Node

image

Evaluates incoming Message with configured JavaScript condition.

JavaScript function receive 3 input parameters:

Script should return Boolean value. If True - send Message via True chain, otherwise False chain is used.

image

Message payload can be accessed via msg variable. For example msg.temperature < 10;
Message metadata can be accessed via metadata variable. For example metadata.customerName === 'John';
Message type can be accessed via msgType variable. For example msgType === 'POST_TELEMETRY_REQUEST'

Full script example:

if(msgType === 'POST_TELEMETRY_REQUEST') {
    if(metadata.deviceType === 'vehicle') {
        return msg.humidity > 50;
    } else if(metadata.deviceType === 'controller') {
        return msg.temperature > 20 && msg.humidity > 60;
    }
}

return false;

JavaScript condition can be verified using Test JavaScript function.

You can see the real life examples, where this node is used, in the next tutorials:

Switch Node

image

Routes incoming Message to one OR multiple output chains. Node executes configured JavaScript function.

JavaScript function receive 3 input parameters:

The script should return an array of next Relation names where Message should be routed. If returned array is empty - message will not be routed to any Node and discarded.

image

Message payload can be accessed via msg variable. For example msg.temperature < 10;
Message metadata can be accessed via metadata variable. For example metadata.customerName === 'John';
Message type can be accessed via msgType variable. For example msgType === 'POST_TELEMETRY_REQUEST'

Full script example:

if (msgType === 'POST_TELEMETRY_REQUEST') {
    if (msg.temperature < 18) {
        return ['Low Temperature Telemetry'];
    } else {
        return ['Normal Temperature Telemetry'];
    }
} else if (msgType === 'POST_ATTRIBUTES_REQUEST') {
    if (msg.currentState === 'IDLE') {
        return ['Idle State', 'Update State Attribute'];
    } else if (msg.currentState === 'RUNNING') {
        return ['Running State', 'Update State Attribute'];
    } else {
        return ['Unknown State'];
    }
}
return [];

JavaScript switch function can be verified using Test JavaScript function.

In order to specify custom relation name Custom type should be selected. This will allow to input custom relation name. Custom relation names are case-insensitive.

image