Data Flow to and from NodeRed through a Codec

I’m trying to build an application where

  • some sensors upload data
  • in NodeRed i do a bit of repackaging etc and
  • a download is constructed
  • which is then downloaded to a display node

I have a “device profile” with a codec (in javascript) implementing both decodeDownlink and encodeUplink.

Uploads pass through decodeDownlink which creates a nested object structure, does scaling etc so i get nice measurements in NodeRed (and the influx integration). Fine.

Now the issue:
I have found no way to create/pass an object structure to NodeRed “device downlink” that is passed through the codecs encodeDownlink.
If i create the binary data in NodeRed, i can pass downloads - which are then sent correctly to the display node.

I would like to stay on objects on the NodeRed side and do all en/decoding in the JS codec.

BTW; if i pass a JSON objects (“equal” to what i want to used on the NodeRed end) directly to the nodes “Queue” - it passes through the encodeDownlink in Codec …