Thingsboard - split messages in rule chain

1k views Asked by At

I need to have a "script node" in rule chain to return more than one message. I'm working on two different projects, and in both project I need this feature. For example because I need to invoke a dynamic number of API request. Using node-red I can obtain this effect by using the "split" node, but Thingsboard doesn't have any similar node.

I've found a "trick solution" that works in this manner:

  1. I create an array of messages as output of my "script node"
  2. the output is propagated to a set of N similar node, and each node will process only the i-th message of the array

It's obviously that this is not a good solution for a production environment, because it generates lots of useless messages and because there is a predefined maximum number of messages (=N) that can be processed at time

I'm using Thingsboard Community Edition

Any suggestion will be very appreciate :)

1

There are 1 answers

0
emem On

New version of Thingsboard(v3.2.1) have been release which includes support for

Added ability to return arrays in transformation script node

https://thingsboard.io/docs/reference/releases/#v321-january-26-2021

In my case I have aggregated telemetry which I need to split and create multiple entries with different timestamps. Works very well. you just need to return array from transformation script node.

Note: in the "test transformer function" screen for testing scripts I am not able to test properly and still get the error wrong result type: ARRAY or similar.