TTN payload decoder to work with mydevices/cayenne

Dear TTN-fellows,

I would to integrate my Bosch BME280 temperature, moisture, pressure and altitude sensor to a cayenne/mydevices integration. I am using following code:

function Decoder (bytes, port) {
// Sign-extend 16 bits to 32 bits to support negative values
var temp = (bytes [0] << 24 >> 16 | bytes [1]) /10;
// MSB, unsigned
var humidity = (bytes [2] << 8 | bytes [3]);
var pressure = (bytes [4] << 8 | bytes [5]);
var altitude = (bytes [6] << 8 | bytes [7]);
return {
Temperature: temp,
Humidity: humidity/10,
Pressure_mB: pressure,
Altitude: altitude,
};
}

Can you please help me rewrite the payload decoder to comply with the cayenne format? I have screened following topics:


https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload

My sensor node is already out in the field, I don’t want to open it again.

Thank you!