How to decode payload

Good morning all,

For the past few days, I have been trying to decode the data from this https://www.xterconnect.com/security-products/sfit5-l.
I’m not really good at javascript. One of you can help me figure out how to decode payload or help me understand how payload decode works depending on my sensor.
According to the documentation, it is possible to change the sensor parameters, for example stop night mode, if so how can I do it?

Here is the doc for the payload decode:
https://www.scm-pc-card.de/media/pdf/9f/eb/67/Payload-spec-command-V203.pdf

pdf link of the sensor:
https://www.scm-pc-card.de/media/pdf/8c/eb/94/SFIT5-L-Datasheet-EN.pdf

I’m trying to get as much documentation as possible on the subject, mostly with @arjanvanb’s posts which are really enriching.but but I don’t understand yet how to do my own code ^^

Thank you to you who will take the time to answer my problem
I’ve started doing this, but it’s not quite functional. ^^

function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
  var decoded = {};

  decoded.cmd = bytes[0];
 
  if (decoded.cmd == 16 | decoded.cmd == 32 | decoded.cmd == 48){
    decoded.hours = bytes[1]
    decoded.minutes = bytes[2]
    decoded.pio0_present = bytes[3]
    decoded.pio1_present = bytes[4]
    decoded.pio2_present = bytes[5]
    decoded.pio3_present = bytes[6]
    decoded.intTemp_present = (bytes[7] & 0x01) ? true : false
    decoded.extTemp_present = (bytes[8] & 0x01) ? true : false
    decoded.vbat_present = (bytes[9] & 0x01) ? true : false
    decoded.vext_present = (bytes[10] & 0x01) ? true : false
    if (decoded.pio0_present) {
      decoded.pio0_event = bytes[12]
    }
    
    if (decoded.pio1_present) {
      decoded.pio1_event = bytes[13]
    }
    
    if (decoded.pio2_present) {
      decoded.pio2_event = bytes[12]
    }
    
    if (decoded.pio3_present) {
      decoded.pio3_event = bytes[13]
    }
    
    if (decoded.intTemp_present) {
      decoded.intTemp = bytes[14]
    }
    
    if (decoded.extTemp_present) {
      decoded.extTemp = bytes[15]
    }
    
    if (decoded.vbat_present) {
      decoded.Vbat = bytes[16]
    }
    
    if (decoded.vext_present) {
      decoded.Vext = bytes[17]
    }
    
  }
 
  else if (decoded.cmd === 0) {
    decoded.config_exist = bytes[1];
    decoded.hours = bytes[2]
    decoded.minutes = bytes[3]
    decoded.guardTimeDay = bytes[4]
    decoded.guardTimeNight = bytes[5]
    decoded.KeepAliveValue = bytes[6]
    decoded.pio0EventThresholdDay = bytes[7]
    decoded.pio0EventThresholdNight = bytes[8]
    decoded.pio1EventThresholdDay = bytes[9]
    decoded.pio1EventThresholdNight = bytes[10]
    decoded.pio2EventThresholdDay = bytes[11]
    decoded.pio2EventThresholdNight = bytes[12]
    decoded.pio3EventThresholdDay = bytes[13]
    decoded.pio3EventThresholdNight = bytes[14]
    decoded.nightStartHours = bytes[15]
    decoded.nightStartMinutes = bytes[16]
    decoded.dayStartHours = bytes[17]
    decoded.dayStartMinutes = bytes[18]
    decoded.en_Register = bytes[19]
    
    
  }

  return decoded;
}

There is no semicolons!

Here with semicolons.
function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var decoded = {};

  decoded.cmd = bytes[0];

  if (decoded.cmd == 16 | decoded.cmd == 32 | decoded.cmd == 48){
    decoded.hours = bytes[1];
    decoded.minutes = bytes[2];
    decoded.pio0_present = bytes[3];
    decoded.pio1_present = bytes[4];
    decoded.pio2_present = bytes[5];
    decoded.pio3_present = bytes[6];
    decoded.intTemp_present = (bytes[7] & 0x01) ? true : false;
    decoded.extTemp_present = (bytes[8] & 0x01) ? true : false;
    decoded.vbat_present = (bytes[9] & 0x01) ? true : false;
    decoded.vext_present = (bytes[10] & 0x01) ? true : false;
    if (decoded.pio0_present) {
      decoded.pio0_event = bytes[12];
    }
    
    if (decoded.pio1_present) {
      decoded.pio1_event = bytes[13];
    }
    
    if (decoded.pio2_present) {
      decoded.pio2_event = bytes[12];
    }
    
    if (decoded.pio3_present) {
      decoded.pio3_event = bytes[13];
    }
    
    if (decoded.intTemp_present) {
      decoded.intTemp = bytes[14];
    }
    
    if (decoded.extTemp_present) {
      decoded.extTemp = bytes[15];
    }
    
    if (decoded.vbat_present) {
      decoded.Vbat = bytes[16];
    }
    
    if (decoded.vext_present) {
      decoded.Vext = bytes[17];
    }
    
  }
 
  else if (decoded.cmd === 0) {
    decoded.config_exist = bytes[1];
    decoded.hours = bytes[2];
    decoded.minutes = bytes[3];
    decoded.guardTimeDay = bytes[4];
    decoded.guardTimeNight = bytes[5];
    decoded.KeepAliveValue = bytes[6];
    decoded.pio0EventThresholdDay = bytes[7];
    decoded.pio0EventThresholdNight = bytes[8];
    decoded.pio1EventThresholdDay = bytes[9];
    decoded.pio1EventThresholdNight = bytes[10];
    decoded.pio2EventThresholdDay = bytes[11];
    decoded.pio2EventThresholdNight = bytes[12];
    decoded.pio3EventThresholdDay = bytes[13];
    decoded.pio3EventThresholdNight = bytes[14];
    decoded.nightStartHours = bytes[15];
    decoded.nightStartMinutes = bytes[16];
    decoded.dayStartHours = bytes[17];
    decoded.dayStartMinutes = bytes[18];
    decoded.en_Register = bytes[19];
    
    
  }
  return decoded;
}

You can experiment here with payloads and results.Edit accordingly.

According to documentation you provided. you have for sure another one mistake at bytes[7-14]. [7] is MSB [8] is LSB.