Rodrigo Honorio
Rodrigo Honorio

Reputation: 13

How to aggregate telemetry data from different devices contained in one asset?

I'm working with Thingsboard Community Edition 2.0.

I have one asset that contains two different devices. Both devices send telemetry data with the same key. I want to be able to show the sum of both values as the total for the asset. Did anyone figure out how to do it?

Thanks.

Upvotes: 1

Views: 2133

Answers (1)

Corentin B
Corentin B

Reputation: 21

The idea is basically to create a memory attribute containing a JSON of the data you want to save. It's not straight forward but i found a way that works to do it.

Main steps :

  • Change originator to asset.
  • Each time telemetry comes, use enrichment to get the attribute memory, then with a script node put if from metadata to msg.
  • Merge the memory and the incomming telemetry (replace old value with new ones)
  • Compute what you want (min, max, mean, standard deviation, sum, etc...) and save it in telemetry or attribute.
  • Save in parallel the merged memory (note you can't save JS objects in telemetry or attributes, you have to use JSON.stringify() to save it and JSON.parse to take it back using enrichment node.

Hope it helps Corentin

Upvotes: 1

Related Questions