1

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 :)

  • Another workaround is to have multiple script nodes, where each one is responsible for one message. Yet another workaround is to perform the requests directly from the scriptnode. – lupz Oct 07 '20 at 12:14
  • Thank you for your reply. The first solution is very similar to mine. The second one is the best solution in general, but is not applicable in my context because i've to invoke a RESTful API call on each message, anfmd I can't fo that from inside the script node. I think I have to forward my flow to a nodered instance – Francesco C. Oct 15 '20 at 16:56

1 Answers1

0

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.

emem
  • 151
  • 4