thingsboard: reformat shared attribute JSON before publishing via MQTT

25 views Asked by At

I need to send configuration data to a device from Thingsboard (CE) via MQTT. The device expects a specific JSON structure and changing the firmware of the device is not an option.

I looked into the client side RPC API but the required pub/sub scheme is not supported by the device.

I looked into the Attributes API which seemed promising.

I tried to use the JSON value support for shared attributes but it stores and subsequntly publishes the attribute as a key/value pair with my JSON as the value:

{
"sharedAttributeKey": {
    "myKey1": "myValue1,
    "myKey2": "myValue2"
    }
}

But I need it so publish:

{
  "myKey1": "myValue1,
  "myKey2": "myValue2"
}

I tried to use the rule chain to reformat the JSON to the required format, but Thingsboard publishes the message before the rule chain is executed. What am I doing wrong? Any helo would be highly aprreciated.

0

There are 0 answers