Stand with Ukraine flag
Try it now Pricing
Edge
Documentation > Key concepts > Attributes
Getting Started
Devices Library Installation Architecture API FAQ
On this page

Edge Attributes

Overview

Custom attributes are the structured data that can be assigned to the entities. They are stored in the database and can be used for visualization, analysis, logic configuration, and integration with other services.

In ThingsBoard Edge, attributes work similarly to the ThingsBoard platform. For a comprehensive understanding of the ThingsBoard Attributes, please refer to the Working with IoT Attributes documentation.

Assigning Attributes to the Edge Entities

Custom attributes can be managed from the Edge instance. They are stored and processed locally for immediate use.

To add an attribute to any Edge entity:

  • Go to the Entity section (e.g. Entities > Devices section) and click on the entity. On the Entity details page, select the “Attributes” tab and select the “Server attributes” option in the “Entity attributes scope” drop-down menu.
  • Click the “Add” button. In the “Add attribute” window, enter the attribute name in the “Key” field. Then, select the attribute value (String, Integer, Double, Boolean, JSON) type and input an attribute value in the corresponding fields. Click the “Add” button.
  • Once the attribute is added, you can see it in the list

If an attribute is assigned to an entity on the ThingsBoard Server, and the entity is then assigned to an Edge instance, the attribute is automatically assigned as well. Read about how to assign entities to the Edge instance here.

Using Attributes to Visualize Data on the Dashboard

In visualization data process, entity attributes can be used to provide context for telemetry data, display static or dynamic metadata about devices, and act as configuration parameters to filter or annotate dashboards.

To display attributes on the Dashboard, create the Entity alias and bind it to the widget. Widgets like Cards, Input widgets, or Entity Tables are ideal for displaying attributes.

Read more about Edge Dashboards configuration here.

Syncing Attribute Updates

To ensure that any changes to the attributes are synchronized between the Server and Edge instances, adjust the Rule Chains.

If the changes occurred on the ThingsBoard Server and must be propagated to the Edge instance:

  • Log in to the ThingsBoard Server, go to the Rule chains section and click on the Rule Chain.
  • On the Rule Chain edit page, find the “push to edge” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. Then, in the “Add rule node” pop-up window enter the node title and select the “Server attributes” option in the “Entity attributes scope” field. Click the “Add” button to proceed.
  • Connect the “message type switch” node and the “push to edge” node with the “Attributes Deleted” and “Attributes Updated” link labels. Click the “Apply changes” button on the Rule Chain sheet.

To keep the ThingsBoard Server up to date with any attribute changes that have occurred on the Edge:

  • Log in to the ThingsBoard Server, go to the Edge management > Rule chains templates section and click on the Rule Chain.
  • On the Rule Chain edit page, find the “push to cloud” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. Then, in the “Add rule node” pop-up window enter the node title and select the “Server attributes” option in the “Entity attributes scope” field. Click the “Add” button to proceed.
  • Connect the “message type switch” node and the “push to cloud” node with the “Attributes Deleted” and “Attributes Updated” link labels. Click the “Apply changes” button on the Rule Chain sheet.

Read about how to subscribe to device attributes change here.

Custom Attributes for Edge Instance

Starting with the 3.9.0 release, custom attributes can be assigned to the Edge instance and used as placeholders in the Rule Chains. This allows each Edge instance to dynamically replace placeholders with its specific attributes in real time. In this way, one Edge Rule Chain template can be used for multiple instances, eliminating the need to create a separate Rule Chain template for each Edge instance. The retrieved Edge attributes can be used for metadata enrichment, authentication and tagging, analysis, and contextualization of transmitted data. This approach streamlines the management of multiple Edge instances and supports efficient scaling while minimizing errors and simplifying maintenance.

To assign a custom attribute to the Edge instance, follow these steps:

  • Log in to the ThingsBoard Server, go to the Edge management > Instances section and click on the Edge instance. On the “Edge details” page, select the “Attributes” tab.
  • Click the “Add” button and add a new custom attribute (e.g. edgeAccessToken).
  • Confirm the assigned attribute.
  • Select the “Relations” tab and click the “Add” button to add a new relation (e.g. the relation between the Edge and the Device(s)). Click the “Add” button.
  • The newly created relations will appear in the “Relations” tab.

To use Edge attributes as placeholders in the Rule Chain template:

  • Go to the ThingsBoard Server, the Edge management > Rule chains templates section and click on the Rule Chain in question.
  • On the Rule Chain edit page, find the “related entity data” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. Fill in the following fields in the pop-up window:
    • Name: Enter the node name.
    • Direction: Select the relation direction (From originator/To originator).
    • Relation type: Select the relation type (Contains/Manages).
    • Entity types: Add the entity type.
  • Scroll down and continue with the configuration. In the “Data to fetch” configuration block, select the “Attributes” tab and enter the “Attributes mapping” parameters:
    • Source attribute key: Enter the entity attribute key you want to track.
    • Target key: Enter the target key name. Click the “Add” button.
  • Then, find the “rest api call” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. In the pop-up window, enter the node name and click the “Add” button.
    • Name: Enter the node name.
    • Headers: Enter the request header and value. The header or value can be a static string, or pattern that is resolved using Message Metadata properties.
    • Click the “Add” button. Read more about the REST API Call node configuration here.
  • Connect the “message type switch” and “related entity data” nodes with the “Post telemetry” link label. Then, connect the “related entity data” and “rest api call” nodes with the “Success” link label. Click the “Apply changes” button on the Rule Chain sheet.

Using Attributes in Edge Rule Chains

In ThingsBoard Edge, Rule Chains can leverage edge attributes to create dynamic, real-time data processing logic.

Let’s consider a situation in which it is necessary to be notified whenever any device attribute undergoes a change.

Before configuring the alarm notifications, have these steps completed:

Follow these steps to configure the alarm notifications:

  • Log in to the ThingsBoard Server, go to the Edge management > Rule chains templates section and click on the Rule Chain in question.
  • On the Rule Chain edit page, find the “related entity data” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. Fill in the following fields in the pop-up window:
    • Name: Enter the node name.
    • Direction: Select the relation direction (From originator/To originator).
    • Relation type: Select the relation type (Contains/Manages).
    • Entity types: Add the entity type.
  • Scroll down and continue with the configuration. In the “Data to fetch” configuration block, select the “Attributes” tab and enter the “Attributes mapping” parameters:
    • Source attribute key: Enter the entity attribute key you want to track.
    • Target key: Enter the target key name. Click the “Add” button.
  • Then, find the “create alarm” node using the Node search bar. Drag and drop the node onto the Rule Chain sheet. In the pop-up window, enter the node name and click the “Add” button.
  • Connect the “message type switch” and “related entity data” nodes with the “Attributes Updated” and “Attributes Deleted” link labels. Then, connect the “related entity data” and “create alarm” nodes with the “Success” link label. Click the “Apply changes” button on the Rule Chain sheet.
  • To verify if the Alarm notification will be sent, go to the Entities > Devices section, and open the “Attributes” tab on the “Device details” page. Change the attribute you added to the “related entity data” node.
  • Confirm the received Alarm notification.
Doc info icon

Be sure to Acknowledge and Clear the notification when you receive it. You can do this either in the Cloud or on the Edge. If the unacknowledged alert exists, it will be updated rather than created.