@pst-on-npm/homebridge-enocean
Version:
Integrate EnOcean® devices into Homebridge.
107 lines • 5.27 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EepParser_A5_02 = void 0;
const EnoCore = __importStar(require("enocean-core"));
const EepParser_1 = require("./EepParser");
const util_1 = require("../util");
/**
* A5-02: 4BS - Temperature Sensors
*
* Supported type:
*
* 01-0B, 10-19, 1A, 1B
*/
class EepParser_A5_02 extends EepParser_1.EepParser {
_limitsOfType = {
0x01: { max: 0, m: 255 / 40 }, // TYPE 01 Temperature Sensor Range -40°C to 0°C
0x02: { max: 10, m: 255 / 40 }, // TYPE 02 Temperature Sensor Range -30°C to 10°C
0x03: { max: 20, m: 255 / 40 }, // TYPE 03 Temperature Sensor Range -20°C to 20°C
0x04: { max: 30, m: 255 / 40 }, // TYPE 04 Temperature Sensor Range -10°C to 30°C
0x05: { max: 40, m: 255 / 40 }, // TYPE 05 Temperature Sensor Range 0°C to 40°C
0x06: { max: 50, m: 255 / 40 }, // TYPE 06 Temperature Sensor Range 10°C to 50°C
0x07: { max: 60, m: 255 / 40 }, // TYPE 07 Temperature Sensor Range 20°C to 60°C
0x08: { max: 70, m: 255 / 40 }, // TYPE 08 Temperature Sensor Range 30°C to 70°C
0x09: { max: 80, m: 255 / 40 }, // TYPE 09 Temperature Sensor Range 40°C to 80°C
0x0A: { max: 90, m: 255 / 40 }, // TYPE 0A Temperature Sensor Range 50°C to 90°C
0x0B: { max: 100, m: 255 / 40 }, // TYPE 0B Temperature Sensor Range 60°C to 100°C
0x10: { max: 20, m: 255 / 80 }, // TYPE 0C Temperature Sensor Range -60°C to 20°C
0x11: { max: 30, m: 255 / 80 }, // TYPE 0D Temperature Sensor Range -50°C to 30°C
0x12: { max: 40, m: 255 / 80 }, // TYPE 0E Temperature Sensor Range -40°C to 40°C
0x13: { max: 50, m: 255 / 80 }, // TYPE 0F Temperature Sensor Range -30°C to 50°C
0x14: { max: 60, m: 255 / 80 }, // TYPE 10 Temperature Sensor Range -20°C to 60°C
0x15: { max: 70, m: 255 / 80 }, // TYPE 11 Temperature Sensor Range -10°C to 70°C
0x16: { max: 80, m: 255 / 80 }, // TYPE 12 Temperature Sensor Range 0°C to 80°C
0x17: { max: 90, m: 255 / 80 }, // TYPE 13 Temperature Sensor Range 10°C to 90°C
0x18: { max: 100, m: 255 / 80 }, // TYPE 14 Temperature Sensor Range 20°C to 100°C
0x19: { max: 110, m: 255 / 80 }, // TYPE 15 Temperature Sensor Range 30°C to 110°C
0x1A: { max: 120, m: 255 / 80 }, // TYPE 16 Temperature Sensor Range 40°C to 120°C
0x1B: { max: 130, m: 255 / 80 }, // TYPE 17 Temperature Sensor Range 50°C to 130°C
0x20: { max: 41.2, m: 1024 / 51.2 }, // TYPE 20 Temperature Sensor Range -10°C to 41.2°C (10bit)
0x30: { max: 62.3, m: 1024 / 102.3 }, // TYPE 30 Temperature Sensor Range -40°C to 62.3°C (10bit)
};
_limits;
/**
* Initializes an instance of EepParser_A5_02
* @param type the EEP type
*/
constructor(type) {
super(type);
if (type in this._limitsOfType) {
this._limits = this._limitsOfType[type];
}
else {
throw new Error(`${util_1.Util.toHexString(type)}: EEP type not supported`);
}
}
parse(telegram) {
this.assertROrg(EnoCore.RORGs.FOURBS, telegram);
const db1 = telegram.getDB(1);
const db2 = telegram.getDB(2);
const value = (this.eepType & 0x20) === 0x20
? ((db2 & 0x03) << 8) | db1 // 10 bit
: db1; // 8 bit
const eep = super.parseBase(telegram);
eep.values.temperature = this._limits.max - value / this._limits.m;
return eep;
}
toString(values) {
const type = this.eepType.toString(16).padStart(2, '0').toUpperCase();
const temp = values.temperature?.toFixed(1);
return `${this.constructor.name}-${type}: T=${temp} °C`;
}
}
exports.EepParser_A5_02 = EepParser_A5_02;
//# sourceMappingURL=EepParser_A5_02.js.map