UNPKG

node-enocean-ts

Version:

Typescript full implementation of the enocean protocol (ESP3 + EEP2.6)

49 lines 1.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const eepHelper_1 = __importDefault(require("./eepHelper")); function default_1(eep, data) { var ret = null; var eepa = eep.split("-"); var choice = eepa[0]; var func = eepa[1]; var type = eepa[2]; var typeNr = parseInt(type, 16); if (choice === "d2" && func === "32" && type == 2) { var rawVal1 = parseInt(data.substring(2, 5), 16); var rawVal2 = parseInt(data.substring(5, 8), 16); var rawVal3 = parseInt(data.substring(8, 11), 16); var powerFailBit = eepHelper_1.default.extractBitValue(0, 7, 1, data.substring(0, 2)); var scaleBit = eepHelper_1.default.extractBitValue(0, 6, 1, data.substring(0, 2)); var devisor = 1; if (scaleBit == 1) { devisor = 10; } return [{ type: "scale", unit: "", value: 1 / devisor }, { type: "current", unit: "A", value: rawVal1 / devisor }, { type: "current", unit: "A", value: rawVal2 / devisor }, { type: "current", unit: "A", value: rawVal3 / devisor }, { type: "power_fail", unit: "", value: powerFailBit }]; } return ret; } //# sourceMappingURL=eep-d2-32-02.js.map