ThingsBoard provides the ability to assign custom attributes to your entities and manage these attributes. Attributes are treated key-value pairs. Flexibility and simplicity of the key-value format allow easy and seamless integration with almost any IoT device on the market.
Attributes are separated into three main groups:
server-side - attributes are reported and managed by the server-side application. Not visible to the device application. Some secret data that may be used by thingsboard rules but should not be available to the device. Any ThingsBoard entity supports server-side attributes: Device, Asset, Customer, Tenant, Rules, etc.
All attributes may be used in Rule Engine components: filters, processors, and actions. This guide provides the overview of the features listed above and some useful links to get more details.
Device specific attributes are separated into two main groups:
client-side - attributes are reported and managed by the device application. For example current software/firmware version, hardware specification, etc.
shared - attributes are reported and managed by the server-side application. Visible to the device application. For example customer subscription plan, target software/firmware version.
ThingsBoard provides following API to device applications:
Attributes API is specific for each supported network protocol. You can review API and examples in corresponding reference page:
Telemetry Service is responsible for persisting attributes data to internal data storage; provides server-side API to query and subscribe for attribute updates.
ThingsBoard uses either Cassandra NoSQL database or SQL database to store all data.
Although you can query the database directly, ThingsBoard provides a set of RESTful and Websocket API that simplify this process and apply certain security policies:
Telemetry Service provides following REST API to fetch entity data:
NOTE: The API listed above is available via Swagger UI, please review general REST API documentation for more details. The API is backward compatible with TB v1.0+ and this is the main reason why API call URLs contain “plugin”.
You can fetch list of all attribute keys for particular entity type and entity id using GET request to the following URL
http(s)://host:port/api/plugins/telemetry/{entityType}/{entityId}/keys/attributes
resources/get-attributes-keys.sh |
---|
|
resources/get-attributes-keys-result.json |
---|
|
Supported entity types are: TENANT, CUSTOMER, USER, RULE, DASHBOARD, ASSET, DEVICE, ALARM
You can fetch list of latest values for particular entity type and entity id using GET request to the following URL
http(s)://host:port/api/plugins/telemetry/{entityType}/{entityId}/values/attributes?keys=key1,key2,key3
resources/get-attributes-values.sh |
---|
|
resources/get-attributes-values-result.json |
---|
|
Supported entity types are: TENANT, CUSTOMER, USER, RULE, DASHBOARD, ASSET, DEVICE, ALARM
There are Rule Nodes in the Rule Engine that allows to work with Telemetry Service. Please find more details in node description:
ThingsBoard provides the ability to configure and customize dashboards for data visualization. This topic is covered in a separate guide.
ThingsBoard provides the ability to configure data processing rules. Device attributes can be used inside rule filters. This allows applying rules based on certain device properties. You can find more details in a separate guide.