ADENUIS - Temperature

Sensor

Codec Description

Codec for ADENUIS - Temperature (v1.0.0).

Codec Preview

(function(e){function t(e){switch(typeof e){case"undefined":return"undefined";case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return null===e?"null":"object";}}function r(e){return Object.prototype.toString.call(e).replace(/^\[object *|\]$/g,"")}function a(e){return"function"==typeof e}function n(e){if(null===e||e===void 0)throw TypeError();return Object(e)}function p(e){return e>>0}function l(e){return e>>>0}var u=Math.LN2,y=Math.abs,m=Math.floor,c=Math.log,g=Math.max,f=Math.min,P=Math.pow,h=Math.round;// Paranoia // // (function(){var e=Object.defineProperty,t=!function(){try{return Object.defineProperty({},"x",{})}catch(e){return!1}}();(!e||t)&&(Object.defineProperty=function(t,r,a){if(e)try{return e(t,r,a)}catch(e){}if(t!==Object(t))throw TypeError("Object.defineProperty called on non-object");return Object.prototype.__defineGetter__&&"get"in a&&Object.prototype.__defineGetter__.call(t,r,a.get),Object.prototype.__defineSetter__&&"set"in a&&Object.prototype.__defineSetter__.call(t,r,a.set),"value"in a&&(t[r]=a.value),t})})(),function(){function o(e){if(e=p(e),0>e)throw RangeError("ArrayBuffer size is not a small enough positive integer.");Object.defineProperty(this,"byteLength",{value:e}),Object.defineProperty(this,"_bytes",{value:Array(e)});for(var t=0;te)throw RangeError("length is not a small enough positive integer.");Object.defineProperty(this,"length",{value:e}),Object.defineProperty(this,"byteLength",{value:e*this.BYTES_PER_ELEMENT}),Object.defineProperty(this,"buffer",{value:new o(this.byteLength)}),Object.defineProperty(this,"byteOffset",{value:0})}.apply(this,arguments);if(1<=arguments.length&&"object"===t(arguments[0])&&arguments[0]instanceof i)return function(e){if(this.constructor!==e.constructor)throw TypeError();var t=e.length*this.BYTES_PER_ELEMENT;Object.defineProperty(this,"buffer",{value:new o(t)}),Object.defineProperty(this,"byteLength",{value:t}),Object.defineProperty(this,"byteOffset",{value:0}),Object.defineProperty(this,"length",{value:e.length});for(var r=0;re.byteLength)throw RangeError("byteOffset out of range");if(t%this.BYTES_PER_ELEMENT)throw RangeError("buffer length minus the byteOffset is not a multiple of the element size.");if(void 0===r){var a=e.byteLength-t;if(a%this.BYTES_PER_ELEMENT)throw RangeError("length of buffer minus byteOffset not a multiple of the element size");r=a/this.BYTES_PER_ELEMENT}else r=l(r),a=r*this.BYTES_PER_ELEMENT;if(t+a>e.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:e}),Object.defineProperty(this,"byteLength",{value:a}),Object.defineProperty(this,"byteOffset",{value:t}),Object.defineProperty(this,"length",{value:r})}.apply(this,arguments);throw TypeError()}e.ArrayBuffer=e.ArrayBuffer||o,Object.defineProperty(i,"from",{value:function(e){return new this(e)}}),Object.defineProperty(i,"of",{value:function()/*...items*/{return new this(arguments)}});i.prototype={},Object.defineProperty(i.prototype,"_getter",{value:function(e){if(1>arguments.length)throw SyntaxError("Not enough arguments");if(e=l(e),!(e>=this.length)){var t,r,a=[];for(t=0,r=this.byteOffset+e*this.BYTES_PER_ELEMENT;targuments.length)throw SyntaxError("Not enough arguments");if(e=l(e),!(e>=this.length)){var r,a,n=this._pack(t);for(r=0,a=this.byteOffset+e*this.BYTES_PER_ELEMENT;r=t)return-1;for(var o=0<=a?a:g(t-y(a),0);oarguments.length)throw SyntaxError("Not enough arguments");var e,t,r,a,o,n,p,u,y,m;if("object"==typeof arguments[0]&&arguments[0].constructor===this.constructor){if(e=arguments[0],r=l(arguments[1]),r+e.length>this.length)throw RangeError("Offset plus length of array is out of range");if(u=this.byteOffset+r*this.BYTES_PER_ELEMENT,y=e.length*this.BYTES_PER_ELEMENT,e.buffer===this.buffer){for(m=[],o=0,n=e.byteOffset;othis.length)throw RangeError("Offset plus length of array is out of range");for(o=0;oe.byteLength)throw RangeError("byteOffset out of range");if(a=void 0===a?e.byteLength-t:l(a),t+a>e.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:e}),Object.defineProperty(this,"byteLength",{value:a}),Object.defineProperty(this,"byteOffset",{value:t})}function n(e){return function(r,a){if(r=l(r),r+e.BYTES_PER_ELEMENT>this.byteLength)throw RangeError("Array index out of range");r+=this.byteOffset;for(var o=new Uint8Array(this.buffer,r,e.BYTES_PER_ELEMENT),n=[],d=0;dparseInt(e,16))):new Uint8Array}/** * _ _ * /\ | | (_) * / \ __| | ___ _ _ _ __ _ ___ * / /\ \ / _` |/ _ \ | | | '_ \| / __| * / ____ \ (_| | __/ |_| | | | | \__ \ * /_/ \_\__,_|\___|\__,_|_| |_|_|___/ */var codec;(function(e){var t=/** @class */function(){/** * Constructor * @param options option object * option.codecStorage: implementation of CodecStorage to use for external storage, leave blank if unknown */function t(t){this.parsers=[new e.GenericStatusByteExtParser,new e.Generic0x1fParser,new e.Generic0x20Parser,new e.Generic0x2fParser,new e.Generic0x30Parser,new e.Generic0x33Parser,new e.Generic0x51Parser,new e.Generic0x52Parser,new e.DcStatusByteParser,new e.Dc0x10Parser,new e.Dc0x40Parser,new e.PulseStatusByteParser,new e.Pulse0x10Parser,new e.Pulse0x11Parser,new e.Pulse0x12Parser,new e.Pulse0x30Parser,new e.Pulse0x46Parser,new e.Pulse0x47Parser,new e.Pulse0x48Parser,new e.PulseV30x10Parser,new e.PulseV30x11Parser,new e.PulseV30x12Parser,new e.PulseV30x30Parser,new e.PulseV30x46Parser,new e.PulseV30x47Parser,new e.PulseV30x5aParser,new e.PulseV30x5bParser,new e.TempStatusByteParser,new e.Temp0x10Parser,new e.Temp0x11Parser,new e.Temp0x12Parser,new e.Temp0x30Parser,new e.Temp0x43Parser,new e.TempV3StatusByteParser,new e.TempV30x10Parser,new e.TempV30x30Parser,new e.TempV30x57Parser,new e.TempV30x58Parser,new e.Comfort0x10Parser,new e.Comfort0x4cParser,new e.Comfort0x4dParser,new e.Motion0x10Parser,new e.Motion0x4eParser,new e.Motion0x4fParser,new e.Motion0x50Parser,new e.Motion0x5cParser,new e.Motion0x5dParser,new e.RepeaterStatusByteParser,new e.Repeater0x01Parser,new e.Repeater0x02Parser,new e.Repeater0x03Parser,new e.Repeater0x04Parser,new e.Deltap0x10Parser,new e.Deltap0x11Parser,new e.Deltap0x2fParser,new e.Deltap0x53Parser,new e.Deltap0x54Parser,new e.Deltap0x55Parser,new e.Deltap0x56Parser,new e.AnalogStatusByteParser,new e.Analog0x10Parser,new e.Analog0x11Parser,new e.Analog0x12Parser,new e.Analog0x13Parser,new e.Analog0x14Parser,new e.Analog0x30Parser,new e.Analog0x42Parser,new e.TicStatusByteParser,new e.Tic0x10Parser,new e.Tic0x49Parser,new e.Tic0x4aParser],this.codecStorage=t&&t.codecStorage?t.codecStorage:"undefined"==typeof localStorage?new e.InternalCodecStorage:localStorage}/** * Get supported device types and frame codes. * * The returned pairs are available for decoding. */return t.prototype.getSupported=function(){var e=[];return this.parsers.map(t=>t.deviceType.split("|").map(r=>e.push({deviceType:r,frameCode:t.frameCode}))),e},t.prototype.findDeviceTypes=function(e){if(!/^(?:[0-9a-f]{2}){2,}$/gi.test(e))return[];var t=Buffer.from(e,"hex"),r=t[0],a=this.parsers.filter(e=>e.frameCode===r).map(e=>e.deviceType);return Array.from(new Set(a))},t.prototype.decode=function(e,t,r){if(void 0===t&&(t="tmpDevId"),void 0===r&&(r="unknown"),!/^(?:[0-9a-f]{2}){2,}$/gi.test(e))return{type:"Invalid"};var a,o=Buffer.from(e,"hex"),n=o[0],i=this.fetchDeviceType(t);16===n?(a=o,this.storeConfiguration(a,t)):a=this.fetchConfiguration(t);var p=this.getActiveParsers(i,n),d=p.map(e=>{var t;try{t=e.parseFrame(o,a,r,i)}catch(e){t={error:e.toString()}}return t});p.every(e=>0>e.frameCode)&&d.push({type:"Unsupported"});var s=Object.assign(...[{}].concat(d)),l=s.type;return delete s.type,s=Object.assign({type:l},s),s},t.prototype.setDeviceType=function(e,t){void 0===t&&(t="tmpDevId"),this.codecStorage.setItem(`${t}.deviceType`,e)},t.prototype.clearStoredData=function(e){var t=this;e||(e="tmpDevId"),["deviceType","configuration"].map(t=>`${e}.${t}`).forEach(e=>t.codecStorage.removeItem(e))},t.prototype.fetchConfiguration=function(e){if(!e)return Buffer.from("");var t=this.codecStorage.getItem(`${e}.configuration`);return Buffer.from(t||"","hex")},t.prototype.storeConfiguration=function(e,t){return t?(this.codecStorage.setItem(`${t}.configuration`,e.toString("hex")),e):e},t.prototype.fetchDeviceType=function(e){return e?this.codecStorage.getItem(`${e}.deviceType`)||"":""},t.prototype.storeDeviceType=function(e,t){var r="";if(!t)return r;var a=this.parsers.filter(t=>"any"!==t.deviceType&&t.frameCode===e);return 1===a.length&&(r=a[0].deviceType,this.codecStorage.setItem(`${t}.deviceType`,r)),r},t.prototype.isCompatibleDeviceType=function(e,t){var r=e.deviceType.split("|").filter(e=>e===t);return 0r.isCompatibleDeviceType(a,e)&&(0>a.frameCode||a.frameCode===t));if(0===o.length&&"repeater"!==e){var n=this.parsers.filter(e=>"any"===e.deviceType&&(0>e.frameCode||e.frameCode===t));o=a.concat(n)}if(0r.isCompatibleDeviceType(t,e)&&0===t.frameCode);if(a=a.concat(i),0===i.length){var p=this.parsers.filter(e=>"any"===e.deviceType&&0===e.frameCode);a=a.concat(p)}}return a=a.concat(o),a},t}();e.Decoder=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.builders=[new e.Repeater0x01Builder,new e.Repeater0x02Builder,new e.Repeater0x03Builder,new e.Repeater0x04Builder,new e.Repeater0x05Builder]}/** * Get supported device types and frame codes. * * The returned pairs are available for encoding. */return t.prototype.getSupported=function(){return this.builders.map(e=>({deviceType:e.deviceType,frameCode:e.frameCode}))},t.prototype.getInputDataTypes=function(e,t){var r=this.builders.find(r=>r.deviceType===e&&r.frameCode===t);if(!r)return{};var a={},o=new r.inputDataClass;for(var n in o)o.hasOwnProperty(n)&&(a[n]=typeof o[n]);return a},t.prototype.encode=function(e,t,r,a){void 0===r&&(r="unknown");var o=this.builders.find(r=>r.deviceType===e&&r.frameCode===t);if(!o)return"";var n=o.buildFrame(a||new o.inputDataClass,r);return n.toString("hex")},t}();e.Encoder=t})(codec||(codec={})),"undefined"!=typeof module&&(module.exports=codec),"undefined"!=typeof process&&"test"===process.env.NODE_ENV&&(global.codec=codec);var codec;(function(e){var t=/** @class */function(){function e(){this.store={}}return e.prototype.getItem=function(e){return this.store[e]},e.prototype.removeItem=function(e){delete this.store[e]},e.prototype.setItem=function(e,t){this.store[e]=t},e}();e.InternalCodecStorage=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="analog",this.frameCode=16}return t.prototype.parseFrame=function(t){var r={type:"0x10 Analog configuration"},a={name:"channel A"},o={name:"channel B"};2===t[8]?(r.transmissionPeriodKeepAlive={unit:"s",value:20*t[2]},r.transmissionPeriodData={unit:"s",value:20*t[3]}):(r.transmissionPeriodKeepAlive={unit:"m",value:10*t[2]},r.transmissionPeriodData={unit:"m",value:10*t[3]});var n=this.getDebounceText(t[5]>>4);return a.id=(240&t[4])>>4,a.type=this.getSensorTypeText(15&t[4]),15&t[4]&&(a.threshold=this.getThresholdTriggeringText(3&t[5]),a.externalTrigger={type:this.getThresholdTriggeringText(3&t[5]>>2),debounceDuration:{unit:n[1],value:n[0]}}),n=this.getDebounceText(t[7]>>4),o.id=(240&t[6])>>4,o.type=this.getSensorTypeText(15&t[6]),15&t[6]&&(o.threshold=this.getThresholdTriggeringText(3&t[7]),o.externalTrigger={type:this.getThresholdTriggeringText(3&t[7]>>2),debounceDuration:{unit:n[1],value:n[0]}}),r.channels=[a,o],r.productMode=e.PlateformCommonUtils.getProductModeText(t[8]),r},t.prototype.getSensorTypeText=function(e){return 0===e?"deactivated":1===e?"0-10V":2===e?"4-20mA":""},t.prototype.getThresholdTriggeringText=function(e){return 0===e?"none":1===e?"low":2===e?"high":3===e?"both":""},t.prototype.getDebounceText=function(e){return 0===e?[0,"s"]:1===e?[10,"ms"]:2===e?[20,"ms"]:3===e?[50,"ms"]:4===e?[100,"ms"]:5===e?[200,"ms"]:6===e?[500,"ms"]:7===e?[1,"s"]:8===e?[2,"s"]:9===e?[5,"s"]:10===e?[10,"s"]:11===e?[20,"s"]:12===e?[40,"s"]:13===e?[60,"s"]:14===e?[5,"m"]:[0,"s"]},t}();e.Analog0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="analog",this.frameCode=17}return e.prototype.parseFrame=function(e){var t={type:"0x11 Analog configuration",threshold:{name:"channel A",unit:"\xB5V or 10 nA",high:{value:16777215&e.readUInt32BE(1),hysteresis:16777215&e.readUInt32BE(4)}}};return t},e}();e.Analog0x11Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="analog",this.frameCode=18}return e.prototype.parseFrame=function(e){var t={type:"0x12 Analog configuration",threshold:{name:"channel A",unit:"\xB5V or 10 nA",low:{value:16777215&e.readUInt32BE(1),hysteresis:16777215&e.readUInt32BE(4)}}};return t},e}();e.Analog0x12Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="analog",this.frameCode=19}return e.prototype.parseFrame=function(e){var t={type:"0x13 Analog configuration",threshold:{name:"channel B",unit:"\xB5V or 10 nA",high:{value:16777215&e.readUInt32BE(1),hysteresis:16777215&e.readUInt32BE(4)}}};return t},e}();e.Analog0x13Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="analog",this.frameCode=20}return e.prototype.parseFrame=function(e){var t={type:"0x14 Analog configuration",threshold:{name:"channel B",unit:"\xB5V or 10 nA",low:{value:16777215&e.readUInt32BE(1),hysteresis:16777215&e.readUInt32BE(4)}}};return t},e}();e.Analog0x14Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="analog",this.frameCode=48,this.parser=new e.Analog0x42Parser}return t.prototype.parseFrame=function(e,t,r){var a=this.parser.parseFrame(e,t,r);return a.type="0x30 Analog keep alive",a},t}();e.Analog0x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="analog",this.frameCode=66}return e.prototype.parseFrame=function(e){var t={type:"0x42 Analog data"},r={name:"channel A"},a={name:"channel B"},o=15&e[2],n=16777215&e.readUInt32BE(2);return 1==o?(r.unit="V",r.value=parseFloat((n/1000000).toFixed(3))):2==o?(r.unit="mA",r.value=parseFloat((n/100000).toFixed(3))):r.state="deactivated",o=15&e[6],n=16777215&e.readUInt32BE(6),1==o?(a.unit="V",a.value=parseFloat((n/1000000).toFixed(3))):2==o?(a.unit="mA",a.value=parseFloat((n/100000).toFixed(3))):a.state="deactivated",t.channels=[r,a],t},e}();e.Analog0x42Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="analog",this.frameCode=0}return t.prototype.parseFrame=function(t,r){var a={},o=new e.GenericStatusByteParser;return a=o.parseFrame(t,r),a.alarmChannelA=!!(8&t[1]),a.alarmChannelB=!!(16&t[1]),{status:a}},t}();e.AnalogStatusByteParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="comfort",this.frameCode=16}return e.prototype.parseFrame=function(e){var t={type:"0x10 Comfort configuration",transmissionPeriodKeepAlive:{unit:"s",value:10*e.readUInt16BE(2)},numberOfHistorizationBeforeSending:e.readUInt16BE(4),numberOfSamplingBeforeHistorization:e.readUInt16BE(6),samplingPeriod:{unit:"s",value:2*e.readUInt16BE(8)},calculatedPeriodRecording:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6))},calculatedSendingPeriod:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6)*e.readUInt16BE(4))}};return t},e}();e.Comfort0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="comfort",this.frameCode=76}return e.prototype.parseFrame=function(e){for(var t,r={type:"0x4c Comfort data"},a=[],o=[],n=2;n>4?"active":"inactive",temperature:{unit:"\xB0C",value:e.readInt16BE(3)/10}},alarmHumidity:{alarmStatus:1&e.readUInt8(2)?"active":"inactive",humidity:{unit:"%",value:e.readUInt8(5)}}};return t},e}();e.Comfort0x4dParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="dc",this.frameCode=16}return t.prototype.parseFrame=function(t){var r={type:"0x10 Dry Contacts configuration"};r.productMode=e.PlateformCommonUtils.getProductModeText(t[8]),1===t[8]?(r.keepAlivePeriod={unit:"m",value:10*t.readUInt8(2)},r.transmitPeriod={unit:"m",value:10*t.readUInt8(3)}):(r.keepAlivePeriod={unit:"s",value:20*t.readUInt8(2)},r.transmitPeriod={unit:"s",value:20*t.readUInt8(3)});var a=this.getDebounceText(t[4]>>4),o=this.getTypeText(15&t[4]);return r.channelA="disabled"===o[0]?{type:o[0]}:{type:o[0],edge:o[1],debounceDuration:{unit:a[1],value:a[0]}},a=this.getDebounceText(t[5]>>4),o=this.getTypeText(15&t[5]),r.channelB="disabled"===o[0]?{type:o[0]}:{type:o[0],edge:o[1],debounceDuration:{unit:a[1],value:a[0]}},a=this.getDebounceText(t[6]>>4),o=this.getTypeText(15&t[6]),r.channelC="disabled"===o[0]?{type:o[0]}:{type:o[0],edge:o[1],debounceDuration:{unit:a[1],value:a[0]}},a=this.getDebounceText(t[7]>>4),o=this.getTypeText(15&t[7]),r.channelD="disabled"===o[0]?{type:o[0]}:{type:o[0],edge:o[1],debounceDuration:{unit:a[1],value:a[0]}},r},t.prototype.getTypeText=function(e){return 0===e?["disabled",""]:1===e?["inputPeriodic","high"]:2===e?["inputPeriodic","low"]:3===e?["inputPeriodic","both"]:4===e?["inputEvent","high"]:5===e?["inputEvent","low"]:6===e?["inputEvent","both"]:7===e?["output","high"]:8===e?["output","low"]:["disabled",""]},t.prototype.getDebounceText=function(e){return 0===e?[0,"s"]:1===e?[10,"ms"]:2===e?[20,"ms"]:3===e?[50,"ms"]:4===e?[100,"ms"]:5===e?[200,"ms"]:6===e?[500,"ms"]:7===e?[1,"s"]:8===e?[2,"s"]:9===e?[5,"s"]:10===e?[10,"s"]:11===e?[20,"s"]:12===e?[40,"s"]:13===e?[60,"s"]:14===e?[5,"m"]:15===e?[10,"m"]:[0,"s"]},t}();e.Dc0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="dc",this.frameCode=64}return e.prototype.parseFrame=function(e){var t={type:"0x40 Dry Contacts data",decodingInfo:"true: ON/CLOSED, false: OFF/OPEN",channelA:{value:e.readUInt16BE(2),currentState:!!(1&e[10]),previousFrameState:!!(2&e[10])},channelB:{value:e.readUInt16BE(4),currentState:!!(4&e[10]),previousFrameState:!!(8&e[10])},channelC:{value:e.readUInt16BE(6),currentState:!!(16&e[10]),previousFrameState:!!(32&e[10])},channelD:{value:e.readUInt16BE(8),currentState:!!(64&e[10]),previousFrameState:!!(128&e[10])}};return t},e}();e.Dc0x40Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="dc",this.frameCode=0}return t.prototype.parseFrame=function(t,r){var a={},o=new e.GenericStatusByteParser;return a=o.parseFrame(t,r),{status:a}},t}();e.DcStatusByteParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="deltap",this.frameCode=16}return e.prototype.parseFrame=function(e){var t={type:"0x10 Delta P configuration",transmissionPeriodKeepAlive:{unit:"s",value:10*e.readUInt16BE(2)},numberOfHistorizationBeforeSending:e.readUInt16BE(4),numberOfSamplingBeforeHistorization:e.readUInt16BE(6),samplingPeriod:{unit:"s",value:2*e.readUInt16BE(8)},calculatedPeriodRecording:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6))},calculatedSendingPeriod:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6)*e.readUInt16BE(4))}};return t},e}();e.Deltap0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="deltap",this.frameCode=17}return e.prototype.parseFrame=function(e){var t={type:"0x11 Delta P 0-10V configuration",numberOfHistorizationBeforeSending:e.readUInt16BE(6),numberOfSamplingBeforeHistorization:e.readUInt16BE(2),samplingPeriod:{unit:"s",value:2*e.readUInt16BE(4)},calculatedPeriodRecording:{unit:"s",value:2*(e.readUInt16BE(2)*e.readUInt16BE(4))},calculatedSendingPeriod:{unit:"s",value:2*(e.readUInt16BE(2)*e.readUInt16BE(4)*e.readUInt16BE(6))}};return t},e}();e.Deltap0x11Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="deltap",this.frameCode=47}return e.prototype.parseFrame=function(e){var t={type:"0x2f Delta P Downlink ack",requestStatus:this.getRequestStatusText(e[2])};return t},e.prototype.getRequestStatusText=function(e){return 1===e?"success":2===e?"errorGeneric":3===e?"errorWrongState":4===e?"errorInvalidRequest":"errorOtherReason"},e}();e.Deltap0x2fParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="deltap",this.frameCode=83}return e.prototype.parseFrame=function(e){for(var t={type:"0x53 Delta P periodic data"},r=[],a=2;a>4)},r.threshold=e.readUInt16BE(3),a.type=this.getTypeText(15&e[5]),a.debouncingPeriod={unit:"ms",value:this.getDebouncingPeriodText((240&e[5])>>4)},a.threshold=e.readUInt16BE(6),t.digitalInput1=r,t.digitalInput2=a,t},e.prototype.getDebouncingPeriodText=function(e){return 0===e?0:1===e?10:2===e?20:3===e?500:4===e?100:5===e?200:6===e?500:7===e?1e3:8===e?2e3:9===e?5e3:10===e?1e4:11===e?2e4:12===e?4e4:13===e?6e4:14===e?3e5:15===e?6e5:0},e.prototype.getTypeText=function(e){return 0===e?"deactivated":1===e?"highEdge":2===e?"lowEdge":3===e?"bothEdges":""},e}();e.Generic0x1fParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="any",this.frameCode=32}return t.prototype.parseFrame=function(t,r,a,o){var n={type:"0x20 Configuration"};switch(t.byteLength){case 4:n.loraAdr=!!(1&t[2]),n.loraProvisioningMode=0===t[3]?"ABP":"OTAA",4&t[2]?n.loraDutycyle="activated":("temp3"===o||"pulse3"===o)&&(n.loraDutycyle="deactivated"),n.loraClassMode=32&t[2]?"CLASS C":"CLASS A";break;case 3:n.sigfoxRetry=3&t[2];break;default:n.partialDecoding=e.PartialDecodingReason.MISSING_NETWORK;}return n},t}();e.Generic0x20Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="dc",this.frameCode=47}return e.prototype.parseFrame=function(e){var t={type:"0x2f Downlink ack",downlinkFramecode:`0x${e[2].toString(16)}`,requestStatus:this.getRequestStatusText(e[3])};return t},e.prototype.getRequestStatusText=function(e){return 1===e?"success":2===e?"errorGeneric":3===e?"errorWrongState":4===e?"errorInvalidRequest":"errorOtherReason"},e}();e.Generic0x2fParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="any",this.frameCode=48}return e.prototype.parseFrame=function(){return{type:"0x30 Keep alive"}},e}();e.Generic0x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="dc|pulse3|temp3|comfort|motion||deltap",this.frameCode=51}return e.prototype.parseFrame=function(e){var t={type:"0x33 Set register status",requestStatus:this.getRequestStatusText(e[2]),registerId:e.readUInt16BE(3)};return t},e.prototype.getRequestStatusText=function(e){return 1===e?"success":2===e?"successNoUpdate":3===e?"errorCoherency":4===e?"errorInvalidRegister":5===e?"errorInvalidValue":6===e?"errorTruncatedValue":7===e?"errorAccesNotAllowed":"errorOtherReason"},e}();e.Generic0x33Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="motion|comfort|deltap",this.frameCode=81}return e.prototype.parseFrame=function(e){var t={type:"0x51 digital input 1 alarm",state:{previousFrame:!!(1&e.readUInt8(2)>>1),current:!!(1&e.readUInt8(2)>>0)},counter:{global:e.readUInt32BE(3),instantaneous:e.readUInt16BE(7)}};return t},e}();e.Generic0x51Parser=t})(codec||(codec={}));var codec,__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r>5,hardwareError:!!(4&e[1]),lowBattery:!!(2&e[1]),configurationDone:!!(1&e[1])};return t},e}();e.GenericStatusByteParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="motion",this.frameCode=16}return e.prototype.parseFrame=function(e){var t={type:"0x10 Motion configuration",transmissionPeriodKeepAlive:{unit:"s",value:10*e.readUInt16BE(2)},numberOfHistorizationBeforeSending:e.readUInt16BE(4),numberOfSamplingBeforeHistorization:e.readUInt16BE(6),samplingPeriod:{unit:"s",value:2*e.readUInt16BE(8)},presenceDetectorInhibition:{unit:"s",value:10*e.readUInt16BE(10)},calculatedPeriodRecording:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6))},calculatedSendingPeriod:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6)*e.readUInt16BE(4))}};return t},e}();e.Motion0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="motion",this.frameCode=78}return e.prototype.parseFrame=function(e){var t={type:"0x4e Motion data"},r=[],a=[];t.globalCounterValue=e.readUInt16BE(2);for(var o=4;o>4)},"lora868"===n&&(o.leakageDetection={overflowAlarmTriggerThreshold:t.readUInt16BE(12),threshold:t.readUInt16BE(16),dailyPeriodsBelowWhichLeakageAlarmTriggered:t.readUInt16BE(20)}),r.channels=[a,o],r},t.prototype.inferNetwork=function(e){return 22===e?"lora868":9===e?"sigfox":"unknown"},t.prototype.getStateText=function(e){return e?"enabled":"disabled"},t.prototype.getTypeText=function(e){return e?"gasPullUpOn":"otherPullUpOff"},t.prototype.getHistoricModeText=function(e){return 0===e?"noHistoric":1===e?"historicLogEvery10min":2===e?"historicLogEvery1h":""},t.prototype.getDebouncingPeriod=function(e){return 0===e?0:1===e?1:2===e?10:3===e?20:4===e?50:5===e?100:6===e?200:7===e?500:8===e?1e3:9===e?2e3:10===e?5e3:11===e?1e4:0},t}();e.Pulse0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=17}return e.prototype.parseFrame=function(e){var t={type:"0x11 Pulse configuration"},r={name:"channel A"},a={name:"channel B"};return r.leakageDetection={overflowAlarmTriggerThreshold:e.readUInt16BE(2),threshold:e.readUInt16BE(6)},a.leakageDetection={overflowAlarmTriggerThreshold:e.readUInt16BE(4),threshold:e.readUInt16BE(8)},t.channels=[r,a],t},e}();e.Pulse0x11Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=18}return e.prototype.parseFrame=function(e){var t={type:"0x12 Pulse configuration"},r={name:"channel A"},a={name:"channel B"};return r.leakageDetection={dailyPeriodsBelowWhichLeakageAlarmTriggered:e.readUInt16BE(2)},a.leakageDetection={dailyPeriodsBelowWhichLeakageAlarmTriggered:e.readUInt16BE(4)},t.channels=[r,a],t},e}();e.Pulse0x12Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=48}return e.prototype.parseFrame=function(e){var t={type:"0x30 Pulse keep alive"},r={name:"channel A"},a={name:"channel B"};return r.flow={alarm:!!(1&e[2]),last24hMin:e.readUInt16BE(7),last24hMax:e.readUInt16BE(3)},r.tamperAlarm=!!(4&e[2]),r.leakageAlarm=!!(16&e[2]),a.flow={alarm:!!(2&e[2]),last24hMin:e.readUInt16BE(9),last24hMax:e.readUInt16BE(5)},a.tamperAlarm=!!(8&e[2]),a.leakageAlarm=!!(32&e[2]),t.channels=[r,a],t},e}();e.Pulse0x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=70}return e.prototype.parseFrame=function(e){var t={type:"0x46 Pulse data",decodingInfo:"counterValues: [Channel A, Channel B]",counterValues:[e.readUInt32BE(2),e.readUInt32BE(6)]};return t},e}();e.Pulse0x46Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=71}return e.prototype.parseFrame=function(e){var t={type:"0x47 Pulse alarm",decodingInfo:"flowValues: [Channel A, Channel B]",flowValues:[e.readUInt16BE(2),e.readUInt16BE(4)]};return t},e}();e.Pulse0x47Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse",this.frameCode=72}return e.prototype.parseFrame=function(e){var t={type:"0x48 Pulse historic data"},r=[],a=[],o={name:"channel A"},n={name:"channel B"},i=e[2];t.frameIndex=i,0===i&&(o.index=e.readUInt32BE(3),n.index=e.readUInt32BE(7));for(var p=0===i?11:3,d=this.getBase(i,e.byteLength),s=p;s>4)},"lora868"===n?(o.leakageDetection={overflowAlarmTriggerThreshold:t.readUInt16BE(13),threshold:t.readUInt16BE(17),dailyPeriodsBelowWhichLeakageAlarmTriggered:t.readUInt16BE(21)},o.tamper={activated:!!(128&t[5]),samplePeriodForDetection:{unit:"s",value:10*t.readUInt8(25)},threshold:t.readUInt8(26)}):"sigfox"===n&&(o.tamper={activated:!!(128&t[5])}),r.channels=[a,o],r},t.prototype.inferNetwork=function(e){return 28===e?"lora868":11===e?"sigfox":"unknown"},t.prototype.getStateText=function(e){return e?"enabled":"disabled"},t.prototype.getTypeText=function(e){return e?"gasPullUpOn":"otherPullUpOff"},t.prototype.getDebouncingPeriodText=function(e){return 0===e?0:1===e?1:2===e?10:3===e?20:4===e?50:5===e?100:6===e?200:7===e?500:8===e?1e3:9===e?2e3:10===e?5e3:11===e?1e4:0},t}();e.PulseV30x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=17}return e.prototype.parseFrame=function(e){var t={type:"0x11 Pulse 3 configuration"},r={name:"channel A"},a={name:"channel B"};return r.leakageDetection={overflowAlarmTriggerThreshold:e.readUInt16BE(2),threshold:e.readUInt16BE(6)},a.leakageDetection={overflowAlarmTriggerThreshold:e.readUInt16BE(4),threshold:e.readUInt16BE(8)},t.channels=[r,a],t},e}();e.PulseV30x11Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=18}return e.prototype.parseFrame=function(e){var t={type:"0x12 Pulse 3 configuration"},r={name:"channel A"},a={name:"channel B"};return r.leakageDetection={dailyPeriodsBelowWhichLeakageAlarmTriggered:e.readUInt16BE(2)},r.tamper={samplePeriodForDetection:{unit:"s",value:10*e.readUInt8(6)},threshold:e.readUInt8(7)},a.leakageDetection={dailyPeriodsBelowWhichLeakageAlarmTriggered:e.readUInt16BE(4)},a.tamper={samplePeriodForDetection:{unit:"s",value:10*e.readUInt8(8)},threshold:e.readUInt8(9)},t.channels=[r,a],t},e}();e.PulseV30x12Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=48}return e.prototype.parseFrame=function(e){var t={type:"0x30 Pulse 3 keep alive"},r={name:"channel A"},a={name:"channel B"};return r.flow={alarm:!!(1&e[2]),last24hMin:e.readUInt16BE(7),last24hMax:e.readUInt16BE(3)},r.tamperAlarm=!!(4&e[2]),r.leakageAlarm=!!(16&e[2]),a.flow={alarm:!!(2&e[2]),last24hMin:e.readUInt16BE(9),last24hMax:e.readUInt16BE(5)},a.tamperAlarm=!!(8&e[2]),a.leakageAlarm=!!(32&e[2]),t.channels=[r,a],t},e}();e.PulseV30x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=70}return e.prototype.parseFrame=function(e){var t={type:"0x46 Pulse 3 data",decodingInfo:"counterValues: [Channel A, Channel B]",counterValues:[e.readUInt32BE(2),e.readUInt32BE(6)]};return t},e}();e.PulseV30x46Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=71}return e.prototype.parseFrame=function(e){var t={type:"0x47 Pulse 3 alarm",decodingInfo:"flowValues: [Channel A, Channel B]",flowValues:[e.readUInt16BE(2),e.readUInt16BE(4)]};return t},e}();e.PulseV30x47Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="pulse3",this.frameCode=90}return e.prototype.parseFrame=function(e){for(var t=e.readUInt32BE(2),r={type:"0x5a Pulse 3 data - channel A"},a=[t],o=6;o8<=e)},e.prototype.getLastIds=function(e){return e.filter(e=>8>e)},e.prototype.getByteFromIdsList=function(e){var t=Buffer.alloc(8);return e.forEach((e,r)=>t[r]=e),t.readUInt8(0)},e}();e.Repeater0x04Builder=r})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="repeater",this.frameCode=4}return t.prototype.parseFrame=function(e){var t=__assign({type:"0x04 White List confirmation"},this.getDataFromPayload(e));return t},t.prototype.getDataFromPayload=function(t){var r={};return e.RepeaterHelper.getUPStatusFromPayload(t,r),r.numberOfIdInWl=t.readUInt8(2),r},t}();e.Repeater0x04Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){return function(){}}();e.Repeater0x05InputData=t;var r=/** @class */function(){function e(){this.deviceType="repeater",this.frameCode=5,this.inputDataClass=t}return e.prototype.buildFrame=function(){var e=Buffer.alloc(8);return e[0]=this.frameCode,e},e}();e.Repeater0x05Builder=r})(codec||(codec={}));var codec;(function(e){var t={0:"0x00 The action has been correctly realized"},r={},a=/** @class */function(){function e(){}return e.hex2bin=function(e){return parseInt(e,16).toString(2).padStart(8,"0")},e.getUPStatusFromPayload=function(t,r){var a=t[1],o=1;/^\d$/.test(`${a}`)?(r.frameCounter=0,o=0):r.frameCounter=parseInt(t.readUInt8(1).toString(16).charAt(0),16);var n=t.readUInt8(1).toString(16),i=e.hex2bin(n),p=i[i.length-1];return r.lowBattery="1"===p,r},e.getDownlinkDescriptionForCode=function(e){return r[e]||e},e.getErrorDescriptionForCode=function(e){return t[e]||e},e}();e.RepeaterHelper=a})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="repeater",this.frameCode=0}return e.prototype.parseFrame=function(){return{}},e}();e.RepeaterStatusByteParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="temp",this.frameCode=16}return t.prototype.parseFrame=function(t){var r={type:"0x10 Temperature configuration"},a={name:"probe 1"},o={name:"probe 2"};return 2===t[8]?(r.transmissionPeriodKeepAlive={unit:"s",value:20*t[2]},r.transmissionPeriodData={unit:"s",value:20*t[3]},r.samplingPeriod={unit:"s",value:10*t[10]}):(r.transmissionPeriodKeepAlive={unit:"m",value:10*t[2]},r.transmissionPeriodData={unit:"m",value:10*t[3]},r.samplingPeriod={unit:"m",value:t[10]}),a.id=(240&t[4])>>4,a.threshold=this.getThresholdTriggeringText(3&t[5]),a.state=1&t[9]?"activated":"deactivated",o.id=(240&t[6])>>4,o.threshold=this.getThresholdTriggeringText(3&t[7]),o.state=2&t[9]?"activated":"deactivated",r.probes=[a,o],r.productMode=e.PlateformCommonUtils.getProductModeText(t[8]),r},t.prototype.getThresholdTriggeringText=function(e){return 0===e?"none":1===e?"low":2===e?"high":3===e?"both":""},t}();e.Temp0x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp",this.frameCode=17}return e.prototype.parseFrame=function(e){var t={type:"0x11 Temperature configuration",threshold:{name:"probe 1",unit:"\xB0C",high:{value:e.readInt16BE(2)/10,hysteresis:e[4]/10},low:{value:e.readInt16BE(5)/10,hysteresis:e[7]/10}},superSamplingFactor:e[8]};return t},e}();e.Temp0x11Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp",this.frameCode=18}return e.prototype.parseFrame=function(e){var t={type:"0x12 Temperature configuration",threshold:{name:"probe 2",unit:"\xB0C",high:{value:e.readInt16BE(2)/10,hysteresis:e[4]/10},low:{value:e.readInt16BE(5)/10,hysteresis:e[7]/10}}};return t},e}();e.Temp0x12Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="temp",this.frameCode=48,this.temp0x43Parser=new e.Temp0x43Parser}return t.prototype.parseFrame=function(e,t,r){var a=this.temp0x43Parser.parseFrame(e,t,r);return a.type="0x30 Temperature keep alive",a},t}();e.Temp0x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp",this.frameCode=67}return e.prototype.parseFrame=function(e){var t={type:"0x43 Temperature data"},r={name:"probe 1"},a={name:"probe 2"};return r.id=(240&e[2])>>4,r.unit="\xB0C",r.value=e.readInt16BE(3)/10,a.id=(240&e[5])>>4,a.unit="\xB0C",a.value=e.readInt16BE(6)/10,2!=(15&e[5])&&(r.state=1&e[2]?"activated":"deactivated",a.state=1&e[5]?"activated":"deactivated"),t.temperatures=[r,a],t},e}();e.Temp0x43Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function t(){this.deviceType="temp",this.frameCode=0}return t.prototype.parseFrame=function(t,r){var a={},o=new e.GenericStatusByteParser;return a=o.parseFrame(t,r),a.probe1Alarm=!!(8&t[1]),a.probe2Alarm=!!(16&t[1]),{status:a}},t}();e.TempStatusByteParser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp3",this.frameCode=16}return e.prototype.parseFrame=function(e){var t={type:"0x10 Temp 3 configuration",transmissionPeriodKeepAlive:{unit:"s",value:10*e.readUInt16BE(2)},numberOfHistorizationBeforeSending:e.readUInt16BE(4),numberOfSamplingBeforeHistorization:e.readUInt16BE(6),samplingPeriod:{unit:"s",value:2*e.readUInt16BE(8)},redundantSamples:e.readUInt8(10),calculatedPeriodRecording:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6))},calculatedSendingPeriod:{unit:"s",value:2*(e.readUInt16BE(8)*e.readUInt16BE(6)*e.readUInt16BE(4))}};return t},e}();e.TempV30x10Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp3",this.frameCode=48}return e.prototype.parseFrame=function(e){var t={type:"0x30 Temp 3 keep alive"},r=16&e[1]?2:1,a=[];return a.push({name:"temperature 1",unit:"\xB0C",value:e.readInt16BE(2)/10}),2==r&&a.push({name:"temperature 2",unit:"\xB0C",value:e.readInt16BE(4)/10}),t.temperatures=a,t},e}();e.TempV30x30Parser=t})(codec||(codec={}));var codec;(function(e){var t=/** @class */function(){function e(){this.deviceType="temp3",this.frameCode=87}return e.prototype.parseFrame=function(e){for(var t,r={type:"0x57 Temp 3 periodic data"},a=16&e[1]?2:1,o=[],n=[],i=[],p=2;p`00${(255&e).toString(16)}`.slice(-2)).join("")}function ToTagoFormat(e,t,r=""){const a=[];for(const o in e)if("object"==typeof e[o])for(const r in e[o])a.push({variable:(e[o].MessageType||`${o}_${r}`).toLowerCase(),value:e[o][r],serie:e[o].serie||t});else a.push({variable:`${r}${o}`.toLowerCase(),value:e[o],serie:t});return a}function Decoder(e){var t=new codec.Decoder;const r=device.params.find(e=>"adeunis_type"===e.key)||{value:""};return t.setDeviceType(r.value),t.decode(e)}// let payload = [{ variable: "payload", value: "4040000100000005000201"}] const data=payload.find(e=>"payload_raw"===e.variable||"payload"===e.variable||"data"===e.variable);data&&(serie=new Date().getTime(),payload=Decoder(data.value),delete payload.decodingInfo,payload=ToTagoFormat(payload,serie));

This codec is sourced from TagoIO Github. All rights belong to TagoIO Github.

This codec is licensed under the GNU General Public License v3 (GPL v3). Modifications, if any, are clearly marked. You are free to use, modify, and distribute the codec under the terms of GPL v3.

Community Feedback