Star

ThingsBoard Documentation

Documentation for using ThingsBoard IoT Platform.

Enrichment Nodes

Enrichment Nodes are used to update meta-data of the incoming Message.

Customer attributes
Since TB Version 2.0

image

Node finds Customer of the Message Originator entity and adds Customers Attributes or Latest Telemetry value into Message Metadata.

Administrator can configure the mapping between original attribute name and Metadata attribute name.

There is Latest Telemetry checkbox in the Node configuration. If this checkbox selected, Node will fetch Latest telemetry for configured keys. Otherwise, Node will fetch server scope attributes.

image

Outbound Message Metadata will contain configured attributes if they exist. To access fetched attributes in other nodes you can use this template ‘metadata.temperature

Following Message Originator types are allowed: Customer, User, Asset, Device.

If unsupported Originator type found, an error is thrown.

If Originator does not have assigned Customer Entity Failure chain is used, otherwise Success chain.

You can see the real life example, where this node is used, in the next tutorial:

Device attributes
Since TB Version 2.0

image

Node finds Related Device of the Message Originator entity using configured query and adds Attributes (client\shared\server scope) and Latest Telemetry value into Message Metadata.

Attributes are added into metadata with scope prefix:

For example, shared attribute ‘version’ will be added into Metadata with the name ‘shared_version’. Client attributes will use ‘cs_’ prefix. Server attributes use ‘ss_’ prefix. Latest telemetry value added into Message Metadata as is, without prefix.

In ‘Device relations query’ configuration Administrator can select required Direction and relation depth level. Also Relation type can be configured with required set of Device types.

image

If multiple Related Entities were found, only the first Entity is used for attributes enrichment, other entities will be discarded.

Failure chain is used if no Related Entity was found, otherwise - Success chain.

If attribute or telemetry was not found, it is not added into Message Metadata and still routed via Success chain.

Outbound Message Metadata will contain configured attributes only if they exist.

To access fetched attributes in other nodes you can use this template ‘metadata.temperature

Note: Since TB Version 2.3.1 the rule node has the ability to enable/disable reporting Failure if at least one selected key doesn’t exist in the outbound message.

image

Originator attributes
Since TB Version 2.0

image

Add Message Originator Attributes (client\shared\server scope) and Latest Telemetry value into Message Metadata.

Attributes are added into metadata with scope prefix:

For example, shared attribute ‘version’ will be added into Metadata with the name ‘shared_version’. Client attributes will use ‘cs_’ prefix. Server attributes use ‘ss_’ prefix. Latest telemetry value added into Message Metadata as is, without prefix.

image

Outbound Message Metadata will contain configured attributes if they exist.

To access fetched attributes in other nodes you can use this template ‘metadata.cs_temperature

Note: Since TB Version 2.3.1 the rule node has the ability to enable/disable reporting Failure if at least one selected key doesn’t exist in the outbound message.

image

You can see the real life example, where this node is used, in the following tutorials:

Originator fields
Since TB Version 2.0.1

image

Node fetches fields values of the Message Originator entity and adds them into Message Metadata. Administrator can configure the mapping between field name and Metadata attribute name. If specified field is not part of Message Originator entity fields it will be ignored.

image

Following Message Originator types are allowed: Tenant, Customer, User, Asset, Device, Alarm, Rule Chain.

Failure chain is used If unsupported Originator type found, otherwise - Success chain.

If field value was not found, it is not added into Message Metadata and still routed via Success chain.

Outbound Message Metadata will contain configured attributes only if they exist.

To access fetched attributes in other nodes you can use this template ‘metadata.devType

Since TB Version 2.0

image

Node finds Related Entity of the Message Originator entity using configured query and adds Attributes or Latest Telemetry value into Message Metadata.

Administrator can configure the mapping between original attribute name and Metadata attribute name.

In ‘Relations query’ configuration Administrator can select required Direction and relation depth level. Also set of Relation filters can be configured with required Relation type and Entity Types.

There is Latest Telemetry checkbox in the Node configuration. If this checkbox selected, Node will fetch Latest telemetry for configured keys. Otherwise, Node will fetch server scope attributes.

image

If multiple Related Entities are found, only first Entity is used for attributes enrichment, other entities are discarded.

If no Related Entity found Failure chain is used, otherwise Success chain.

Outbound Message Metadata will contain configured attributes if they exist.

To access fetched attributes in other nodes you can use this template ‘metadata.tempo

You can see the real life example, where this node is used, in the next tutorial:

Tenant attributes
Since TB Version 2.0

image

Node finds Tenant of the Message Originator entity and adds Tenant Attributes or Latest Telemetry value into Message Metadata.

Administrator can configure the mapping between original attribute name and Metadata attribute name.

There is Latest Telemetry checkbox in the Node configuration. If this checkbox selected, Node will fetch Latest telemetry for configured keys. Otherwise, Node will fetch server scope attributes.

image

Outbound Message Metadata will contain configured attributes if they exist. To access fetched attributes in other nodes you can use this template ‘metadata.tempo

Following Message Originator types are allowed: Tenant, Customer, User, Asset, Device, Alarm, Rule Chain.

If unsupported Originator type found, an error is thrown.

Failure chain is used if Originator does not have assigned Tenant Entity, otherwise - Success chain.

Originator telemetry
Since TB Version 2.1.1

image

Adds Message Originator telemetry values from particular time range that was selected in node configuration to the Message Metadata.

image

Telemetry values added to Message Metadata without prefix.

The rule node has three fetch modes:

image

If selected fetch mode FIRST or LAST, Outbound Message Metadata would contain JSON elements(key/value)

Otherwise if the selected fetch mode ALL, telemetry would be fetched as an array.

Note:

The rule node can extract a limit size of records into array: 1000 records

This array will contain JSON objects with the timestamp and value.

Note:

End of the interval must always be less than the beginning of the interval.

If selected checkbox: Use metadata interval patterns, rule node will use Start Interval and End Interval patterns from metadata.

Patterns units sets in the milliseconds since the UNIX epoch (January 1, 1970 00:00:00 UTC)

image

Outbound Message Metadata will contain configured telemetry fields if they exist and belong to the selected range.

If attribute or telemetry was not found, it is not added into Message Metadata and still routed via Success chain.

To access fetched telemetry in other nodes you can use this template: JSON.parse(metadata.temperature)

Note: Since TB Version 2.3 the rule node has the ability to choose telemetry sampling order when selected Fetch mode: ALL.

image

You can see the real-life example, where this node is used, in the following tutorials:

Tenant details
Since TB Version 2.3.1

image

Rule Node Adds fields from Tenant details to the message body or metadata.

There is Add selected details to the message metadata checkbox in the Node configuration. If this checkbox selected, existing fields will be added to the message metadata instead of message data.

image

Selected details are added into metadata with prefix: tenant_. Outbound Message will contain configured details if they exist.

To access fetched details in other nodes you can use one of the following template:

Failure chain is used if Originator does not have assigned Tenant Entity, otherwise - Success chain.

Customer details
Since TB Version 2.3.1

image

Rule Node Adds fields from Customer details to the message body or metadata.

There is Add selected details to the message metadata checkbox in the Node configuration. If this checkbox selected, existing fields will be added to the message metadata instead of message data.

image

Selected details are added into metadata with prefix: customer_. Outbound Message will contain configured details if they exist.

To access fetched details in other nodes you can use one of the following template:

Following Message Originator types are allowed: Asset, Device, Entity View.

If unsupported Originator type found, an error is thrown.

If Originator does not have assigned Customer Entity Failure chain is used, otherwise Success chain.