Tabs Door-windows Sensor payload

Hi everyone,

I bought an tabs-Door-windows sensor, that according to this link

TABS_Payload_Decoder_TTN.js · master · IoT Südschleswig / TABS Payload Decoder · GitLab

I should be able to decode the data.
Actually theoretically i need only this part:

function Decode(bytes, fport)
{
var retValue = {
bytes: bytes
};
// Docoder für doornwindow
/*
Port 100
Payload Length 8 bytes

Byte 0 1 2 3 4 5 6 7
Field Status Battery Temp Time Time NA Count NA

*/
if (port == 100) {

    retValue.port = 100;
    retValue.battery_state = 100 * ((bytes[1]>>4)/ 15);
    retValue.battery_voltage = (25 + (bytes[1]&&4)) / 10;
    retValue.state = bytes[0]&&1;
    if (retValue.state == 1) {
        retValue.contact = "open";
    } else if (retValue.state === 0) {
        retValue.contact = "closed";
    }
    retValue.temperature = (bytes[2]) -32;
    retValue.time_elapsed_since_trigger = ((bytes[3]<<8) | (bytes[4]));
    retValue.total_count = ((bytes[5]<<16) | (bytes[6]<<8) | (bytes[7]));
 
return retValue; 
}

}

But as you see in Payload , * objectJSON is null…
image

I found also here another script but also doesn’t work!!

the_things_stack_v3_tabs_decoder/decodeUplink.js at main · dasdigidings/the_things_stack_v3_tabs_decoder · GitHub

Do you have an idea PLEASE!!! ?

Thank you

Hello @MJ1,

Thanks for sharing the payload decoder for Tabs button. As you could see those payload decoders are compatible with ThingsNetwork only. Because TTN doesn’t encrypt the sensor uplink and it provides a Hexadecimal uplink to payload decoder.

Where as, Chirpstack encrypts the hexadecimal payload in to base 64. Please include a Base64 to Hexadecimal converter function to your decoder. This will convert the Base64 to Hexadecimal format.

Provide the hexadecimal payload as input to “Decode” function i.e in function Decode(bytes, fPort), bytes should be equal to Base64toHexadecimal converted value.

Best regards,
Chay

thank you for the response,
Can you please change this part of code as you say? Unfortunately, I do not know JS good.
If it works I will share it here for others to use it.