Decoder including Dev-EUI

Hi,

I need to forwarding decoded payload to an API Endpoint. Unfortunately one of the objects from the JSON package should contain the device EUI in order to assign the device. I can not change the API Endpoint rules, so I need to send within the decoding Payload the Device EUI. Does anyone have an Idea how I could realize it? This is what I put so far in the decoder, and it misses just the object “Device-EUI”.

function Decoder(bytes, port) {
  
  var params = {
    
};

// Time measurement
time = (bytes[4] << 8) | bytes[3];

// Status measurement
status = bytes[0] & 0x1;
   
params.timestamp = time;
params.type = "PIR"
params.value = status;

return params;
}

Does anyone have an Idea how I can solve it?

Thanks

Regards

AWR

Looks like you are writing a decoder for v2 - this will still work with v3.

The decoder just provides a set of fields for the payload - the API you use will expose other details.

The v3 HTTP Integration includes the DevEUI.

Ok thanks, Just to be sure. If I have an endpoint like https://app.example.com/endpoint/data and want to send to it via HTTP Webhook of v3 a defined JSON package which contains both payload objects and the device-Id it is possible ?

The http integration will send a json message as defined by TTN which contains among many other things the device information (including EUI) and payload.

This is what you receive with webhook. Data Formats | The Things Stack for LoRaWAN

The very best way to be sure is to try it using cURL as per the docs.

Ok, sorry it was my fault. I described it wrong. Actually, I only want to have the following objects in the JSON body:

{
device: "<Dev-EUI>", 
type: "pir"
timestamp: "2021-02-24T10:13:36Z"
value:"1"
}

And nothing else. That means no meta data and so on which is automatically sended as defined by TTN. Can I realize it in TTN respectively TTI or do I need a seperate cloud envirement?

Thanks again.

TTN can’t provide a custom format. You need an intermediate server to translate.