Using the codec on a Milesight gateway via the classic interface
This page explains how to use the decoder for any sensor using the milesight interface (no NodeRED).
Decoding
To start, go into Network Server, in the Payload Codec tab.
In the Payload Decoder Function input area, insert the content of the main.js file of your sensor, from our Github repository (distrib/yourSensor/main.js).
Below the part you pasted, you'll need to add this function:
function Decode(fPort, bytes) {
var _input = {
"bytes": bytes, // The frame in a bytes list
"fPort": fPort, // The port (Watteco always use 125)
"recvTime": new Date().toISOString() // The date in ISO 8601 format
};
return driver.decodeUplink(_input);
}
It should then look like that (the first line might look different depending on the sensor you are using):

Don't forget to give a name to your Custom Payload Codec, to save, and to apply it to your added sensor.
Encoding
To use the encoder, as for the decoder, go into Network Server, in the Payload Codec tab.
In the Payload Encoder Function input area, insert the content of the main.js file of your sensor, from our Github repository (distrib/yourSensor/main.js), the same as inserted in the Payload Decoder Function input area.
Below the part you pasted, you'll need to add this function:
function Encode(fPort, obj) {
return driver.encodeDownlink(obj).bytes;
}
It should then look like that (the first line might look different depending on the sensor you are using):

Don't forget to give a name to your Custom Payload Codec, to save, and to apply it to your added sensor.
BACnet Object Mapping
As for the decoder and encoder, go into Network Server, in the Payload Codec tab.
In the Object Mapping Function input area, insert the content of the yourSensor-milesight-object-mapping.json file of your sensor, from our Github repository (distrib/yourSensor/yourSensor-milesight-object-mapping.json).
It should then look like that with the content depending on the sensor you are using:

Don't forget to give a name to your Custom Payload Codec, to save, and to apply it to your added sensor.
To then add objects, get into Protocole Integration → BACnet Server, in the BACnet Object tab, and you should be able to select and add your sensors objects.
Don't forget to check the Object Type, as sometimes Milesight doesn't read it properly from the Object Mapping, don't hesitate to correct them according to the Object Mapping you got from our GitHub.