node-enocean-ts
Version:
Typescript full implementation of the enocean protocol (ESP3 + EEP2.6)
45 lines • 1.57 kB
JavaScript
;
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 === "a5" && func === "04" && sensors[type] !== undefined) {
var val1 = eepHelper_1.default.extractByteValue(1, 0, 250, sensors[type].tmin, sensors[type].tmax, data);
var val2 = eepHelper_1.default.extractByteValue(2, 0, 250, sensors[type].hmin, sensors[type].hmax, data);
var tempavail = eepHelper_1.default.extractBitValue(0, 1, 1, data);
if (tempavail) {
ret = [{
type: "humidity",
unit: "%rF",
value: val2
}, {
type: "temperature",
unit: "°C",
value: val1
}];
}
else {
ret = [{
type: "humidity",
unit: "%rF",
value: val2
}];
}
return ret;
}
return ret;
}
var sensors = {
"01": { hmin: 0, hmax: 100, tmin: 0, tmax: 40 }, //1
"02": { hmin: 0, hmax: 100, tmin: -20, tmax: 60 } //2
};
//# sourceMappingURL=eep-a5-04-xx.js.map