Action Nodes execute various actions based on incoming Message.
Since TB Version 2.0 |
This Node tries to load latest Alarm with configured Alarm Type for Message Originator. If Uncleared Alarm exist, then this Alarm will be updated, otherwise a new Alarm will be created.
Node Configuration:
Note: Since TB Version 2.3.0 the rule node has the ability to:
read alarm config from message:
get alarm type using pattern with fields from message metadata:
Note: Since TB Version 2.4.3 the rule node has the ability to:
filter propagation to parent entities by relation types:
Alarm Details Builder script used for generating Alarm Details JsonNode. It is useful for storing additional parameters inside Alarm. For example you can save attribute name/value pair from Original Message payload or Metadata.
Alarm Details Builder script should return details object.
msg
property. For example msg.temperature
metadata
property. For example metadata.customerName
msgType
property. For example msgType
Optional: previous Alarm Details can be accessed via metadata.prevAlarmDetails
.
If previous Alarm does not exist, this field will not be present in Metadata. Note that metadata.prevAlarmDetails
is a raw String field and it needs to be converted into object using this construction:
Alarm Details Builder script function can be verified using Test JavaScript function.
Example of Details Builder Function
This function takes count
property from previous Alarm and increment it. Also put temperature
attribute from inbound Message payload into Alarm details.
Alarm created/updated with those properties:
Outbound message will have the following structure:
After new Alarm created, Outbound message will contain additional property inside Metadata - isNewAlarm with true value. Message will be passed via Created chain.
After existing Alarm updated, Outbound message will contain additional property inside Metadata - isExistingAlarm with true value. Message will be passed via Updated chain.
Here is an example of Outbound Message payload
More details about Alarms in the Thingsboard can be found in this tutorial
You can see the real life example, where this node is used, in the next tutorial:
Since TB Version 2.0 |
This Node loads the latest Alarm with configured Alarm Type for Message Originator and Clear the Alarm if it exist.
Node Configuration:
Note: Since TB Version 2.3.0 the rule node has the ability to get alarm type using pattern with fields from message metadata:
Alarm Details Builder script used for updating Alarm Details JsonNode. It is useful for storing additional parameters inside Alarm. For example you can save attribute name/value pair from Original Message payload or Metadata.
Alarm Details Builder script should return details object.
msg
property. For example msg.temperature
metadata
property. For example metadata.customerName
msgType
property. For example msgType
metadata.prevAlarmDetails
.Note that metadata.prevAlarmDetails
is a raw String field and it needs to be converted into object using this construction:
Alarm Details Builder script function can be verified using Test JavaScript function.
Example of Details Builder Function
This function takes count
property from previous Alarm and increment it. Also put temperature
attribute from inbound Message payload into Alarm details.
This Node updates Current Alarm:
In case when Alarm does not exist or it is already Cleared Alarm, original Message will be passed to the next nodes via False chain.
Otherwise new Message will be passed via Cleared chain.
Outbound message will have the following structure:
Here is an example of Outbound Message payload
More details about Alarms in the Thingsboard can be found in this tutorial
You can see the real life example, where this node is used, in the next tutorial:
Since TB Version 2.1 |
Delays incoming messages for configurable period.
Configuration:
When delay period for particular incoming message will be reached it will be removed from pending queue and routed to the next nodes via Success chain.
Each next message will be routed via Failure chain if the maximum pending messages limit will be reached.
Since TB Version 2.0 |
Generates Messages with configurable period. JavaScript function is used for message generation.
Node Configuration:
JavaScript function receive 3 input parameters:
prevMsg
- is a previously generated Message payload.prevMetadata
- is a previously generated Message metadata.prevMsgType
- is a previously generated Message type.Script should return the following structure:
All fields in resulting object are optional and will be taken from previously generated Message if not specified.
Outbound Message from this Node will be new Message that was constructed using configured JavaScript function.
JavaScript generator function can be verified using Test JavaScript function.
This node can be used for Rule Chain debugging purposes.
Since TB Version 2.0 |
Transform incoming Message with configured JavaScript function to String and log final value into the Thingsboard log file.
INFO log level is used for logging.
JavaScript function receive 3 input parameters
metadata
- is a Message metadata.msg
- is a Message payload.msgType
- is a Message type.Script should return String value.
JavaScript transform function can be verified using Test JavaScript function.
You can see the real life example, where this node is used, in the next tutorial:
Since TB Version 2.0 |
Sends response to the RPC Call originator. All incoming RPC requests are passed through Rule Chain as Messages. Also all RPC requests have request ID field. It is used for mapping requests and responses. Message Originator must be a Device entity because RPC response is initiated to the Message Originator.
Node configuration has special request ID field mapping. If the mapping is not specified, requestId metadata field is used by default.
RPC request can be received via different transports:
Message payload example:
Message will be routed via Failure chain in the following cases:
For more details how RPC works in the Thingsboard, please read RPC capabilities Article.
You can see the real life example, where this node is used, in the next tutorial:
Since TB Version 2.0 |
Sends RPC requests to the Device and routing response to the next Rule nodes. Message Originator must be a Device entity as RPC request can be initiated only to device.
Node configuration has Timeout field used to specify timeout waiting for response from device.
Message payload must have correct format for RPC request. It must contains method and params fields. Example:
If Message Payload contains requestId field, its value used to identify RPC request to the Device. Otherwise random requestId will be generated.
Outbound Message will have same originator and metadata as in inbound Message. Response from the Device will be added into Message payload.
Message will be routed via Failure chain in the following cases:
Otherwise Message will be routed via Success chain.
For more details how RPC works in the Thingsboard, please read RPC capabilities article.
Since TB Version 2.0 |
Stores attributes from incoming Message payload to the database and associate them to the Entity, that is identified by the Message Originator. Configured scope is used to identify attributes scope.
Supported scope types:
Expects messages with POST_ATTRIBUTES_REQUEST message type. If message Type is not POST_ATTRIBUTES_REQUEST, Message will be routed via Failure chain.
When attributes are uploaded over existing API (HTTP / MQTT / CoAP / etc.) Message with correct payload and type will be passed into Input node of the Root Rule Chain.
In cases when it is required to trigger attributes saving inside Rule Chain, the Rule Chain should be configured to transform Message payload to the expected format and set message type to POST_ATTRIBUTES_REQUEST. It could be done using Script Transformation Node.
Expected Message Payload example:
After successful attributes saving, original Message will be passed to the next nodes via Success chain, otherwise Failure chain is used.
Since TB Version 2.0 |
Stores Timeseries data from incoming Message payload to the database and associate them to the Entity, that is identified by the Message Originator. Configured TTL seconds is used for timeseries data expiration. 0 value means that data will never expire.
Expects messages with POST_TELEMETRY_REQUEST message type. If message Type is not POST_TELEMETRY_REQUEST, Message will be routed via Failure chain.
When timeseries data is published over existing API (HTTP / MQTT / CoAP / etc.) Message with correct payload and type will be passed into Input node of the Root Rule Chain.
In cases when it is required to trigger timeseries data saving inside Rule Chain, the Rule Chain should be configured to transform Message payload
to the expected format and set message type to POST_TELEMETRY_REQUEST. It could be done using Script Transformation Node.
Message Metadata must contain ts field. This field identifies timestamp in milliseconds of published telemetry.
Also, if Message Metadata contains TTL field, its value is used for timeseries data expiration, otherwise TTL from Node Configuration is used.
Expected Message Payload example:
After successful timeseries data saving, original Message will be passed to the next nodes via Success chain, otherwise Failure chain is used.
Since TB Version 2.3.1 |
Node stores data from incoming Message payload to the Cassandra database into the predefined custom table that should have cs_tb_ prefix, to avoid the data insertion to the common TB tables.
Please note, that rule node can be used only for Cassandra DB.
Configuration:
Administrator should set the custom table name without prefix: cs_tb_.
Administrator can configure the mapping between the Message field names and Table columns name. If the mapping key is $entity_id, that is identified by the Message Originator, then to the appropriate column name(mapping value) will be write the message originator id.
If specified message field does not exist or is not a JSON Primitive, the outbound message will be routed via Failure chain, otherwise, the message will be routed via Success chain.
Since TB Version 2.2 |
Assign Message Originator Entity to Customer.
Following Message Originator types are allowed: Asset, Device, Entity View, Dashboard.
Finds target Customer by customer name pattern and then assign Originator Entity to this customer.
Will create new Customer if it doesn’t exists and Create new Customer if not exists is set to true.
Configuration:
Message will be routed via Failure chain in the following cases:
In other cases Message will be routed via Success chain.
Since TB Version 2.2 |
Unassign Message Originator Entity from Customer.
Following Message Originator types are allowed: Asset, Device, Entity View, Dashboard.
Finds target Customer by customer name pattern and then unassign Originator Entity from this customer.
Configuration:
Message will be routed via Failure chain in the following cases:
In other cases Message will be routed via Success chain.
Since TB Version 2.2.1 |
Create the relation from the selected entity to originator of the message by type and direction.
Following Message Originator types are allowed: Asset, Device, Entity View, Customer, Tenant, Dashboard.
Finds target Entity by metadata key patterns and then create a relation between Originator Entity and the target entity.
If selected entity type Asset, Device or Customer rule node will create new Entity if it doesn’t exist and selected checkbox: Create new Entity if not exists.
Note: if selected entity type Asset or Device you need to set two patterns:
entity name pattern;
entity type pattern.
Otherwise, only name pattern should be set.
Configuration:
Message will be routed via Failure chain in the following cases:
In other cases Message will be routed via Success chain.
Note: Since TB Version 2.3 the rule node has the ability to:
remove current relations from the originator of the incoming message based on direction and type:
change the originator of the incoming message to the selected entity and process outboud messages as messages from another entity:
Since TB Version 2.2.1 |
Delete the relation from the selected entity to originator of the message by type and direction.
Following Message Originator types are allowed: Asset, Device, Entity View, Customer, Tenant, Dashboard.
Finds target Entity by entity name pattern and then delete a relation between Originator Entity and this entity.
Configuration:
Message will be routed via Failure chain in the following cases:
In other cases Message will be routed via Success chain.
Note: Since TB Version 2.3 the rule node has the ability to deletes relation from the originator of the incoming message to the specified entity or to the list of entities based on direction and type by disabling the following checkbox in the rule node configuration:
Since TB Version 2.3.1 |
Produces incoming messages by GPS based parameters. Extracts latitude and longitude from incoming message data or metadata and returns different events based on configuration parameters (geo fence).
The rule node fetches perimeter information from message metadata by default. If Fetch perimeter information from message metadata is unchecked, additional information should be configured.
There are two options of area definition based on the perimeter type:
Polygon
Metadata of the incoming message must include key with name perimeter and following data structure:
There are two options of area definition based on the perimeter type:
There are 4 types of events managed by geofencing rule node:
Administrator can configure duration time threshold for reporting inside or outside event. For example, whenever minimal inside time is set to 1 minute the message originator is considered as being inside the perimeter 60 seconds after entering the area. Minimal outside time defines whenever message originator is considered as out of the perimeter as well.
Failure chain will to be used when: