Hi,
From my MQTT topic I receive sensor data as a timestamp and 25 values, where each value should gets transformed as a datapoint for its own timeseries. However, there is a limit on 2000 char for the transformation code AND a constraint that does not allow you to set up duplicate streams on the same topic: meaning you can only do one transformation per topic, but this function is limited to 2000 chars.
I run into a problem now where, for this sample data:
“{"timestamp":1701093489556,"values":[-0.035999998450279236,-0.10400000214576721,-0.09099999815225601,-0.08299999684095383,-0.09399999678134918,-0.10999999940395355,-0.10700000077486038,-0.10499999672174454,-0.11299999803304672,-0.12099999934434891,-0.13899999856948853,-0.1340000033378601,-0.14399999380111694,-0.1340000033378601,-0.15000000596046448,-0.15000000596046448,-0.17000000178813934,-0.16699999570846558,-0.15399999916553497,-0.16500000655651093,-0.15000000596046448,-0.10199999809265137,-0.11100000143051147,-0.1469999998807907,-0.12600000202655792]}”
I use this template, but cannot include the all 25 values as this is just over 4000 char. Is there a way to get around this? e.g using a loop function to generate the template?
“[From 0…
{
"externalId": concat("mysystem.ExtEnvironment.mysensor.input9.", context.topic),
"timestamp": input.timestamp,
"value": input.values[8],
"type": "datapoint"
},
{
"externalId": concat("mysystem.ExtEnvironment.mysensor.input10.", context.topic),
"timestamp": input.timestamp,
"value": input.values[9],
"type": "datapoint"
},
{
"externalId": concat("mysystem.ExtEnvironment.mysensor,input11.", context.topic),
"timestamp": input.timestamp,
"value": input.values[10],
"type": "datapoint"
},
{
"externalId": concat("mysystem.ExtEnvironment.mysensor.input12.", context.topic),
"timestamp": input.timestamp,
"value": input.values[11],
"type": "datapoint"
},
{
"externalId": concat("mysystem.ExtEnvironment.mysensor..input13.", context.topic),
"timestamp": input.timestamp,
"value": input.values[12],
"type": "datapoint"
}
...up to 25
]”
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support