0

I've trying to setup ThingsBoard for a few days and up to now it's going well. I'm stuck on how to push attributes (sometimes in an aggregate mode - avg, sum, etc) and telemetry data from a Device to its related asset.

Any simple way to do it? I didn't find any API for such.

Thanks

5 Answers5

2

The following is the API for pushing telemetry data for asset, but you also need to be atleast a customer user to use the api i.e need to set authorization token in header as x-authoization: Bearer {JWTtoken}

API: /api/plugins/telemetry/ASSET/{assetId}/timeseries/SERVER_SCOPE/

method : POST

request(example):
{
  "ts": 1563456910227,
  "values": {
    "longitude": "78.381984",
    "latitude": "17.448645",
    "fuel": "30",
    "speed": "42",
    "vehicleType": "bus",
    "status": "On route"
  }
} 
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

Thingsboard supports MQTT, CoAP and HTTP. See https://thingsboard.io/docs/user-guide/telemetry/#device-telemetry-upload-api for details.

Mikael Falkvidd
  • 413
  • 6
  • 13
0

I had a similar problem and was able to fix it by:

(1) in GUI adding a relation from the DEVICE to an associated ENTITY (in my case it was CUSTOMER entity Type)

N.B. here is a related question with a possible solution for creating the relation in code.

then

(2) updating the root rule chain in thingsboard (also via the GUI). Step by step instructions and a picture of my working rule chain canvas can be found in here.

After taking these steps I was not only able to see latest device telemetry show up on latest telemetry for the related customer in the GUI, but also was able to get back the device id in api response to my request for latest telemetry from all devices belonging to a customer.

windsor
  • 379
  • 4
  • 9
0

In rule chain you can do it easily,

first filter the message to make sure you are selecting the right one, then use " Enrichment node" called (duplicate to related) then use save telemetry like attached.

enter image description here

Jackal
  • 21
  • 4
0

Push Data from Device to Asset - Basic Example

You can leverage Rule Engine to do that in real time.

First of all you have to establish a relation between a device and an asset which can be done via the Web UI or REST APIs. Below a screenshot for asset Building A that contains the device Thermostat A:

enter image description here

To push Thermostat A data to the related asset Building A, use a Rule Chain where key steps are changing the message originator from device to related asset, and then saving timeseries (or attributes) for the asset. You can decide whether to perform a double saving (first on device and then on asset, as I've done in the rule chain below) or to store data only at asset level. I consider good practice to store raw data as soon as they're uploaded, and to do additional persistence after further computations if needed.

enter image description here

Push data from Device to Asset - Advanced Example

An advanced version of the above example is described here and it shows the calculation of delta temperature between outdoor and indoor thermostats (the devices) installed into a warehouse (the asset).

Professional Edition Rule Nodes

There are some rule nodes suitable for your purposes, such as Duplicate To Related or Aggregate Stream, but they are available only on the Thingsboard PE edition.

vortex.alex
  • 1,105
  • 3
  • 11
  • 24