@pst-on-npm/homebridge-enocean
Version:
Integrate EnOcean® devices into Homebridge.
107 lines • 4.16 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_3F_7F_Eltako = void 0;
const EnoCore = __importStar(require("enocean-core"));
const EepParser_1 = require("./EepParser");
const util_1 = require("../util");
/**
* A5-3F: 4BS - Central Command
*
* Supported:
*
* 7F Gateway
*/
class EepParser_A5_3F_7F_Eltako extends EepParser_1.EepParser {
_stateMap = {
0x01: 'up', // state moving up
0x02: 'down', // state moving down
0x70: 'open', // Fully open
0x50: 'closed', // Filly closed
};
/**
* Initializes an instance of EepParser_A5_3F_7F
* @param type the EEP type
*/
constructor(type) {
super(type);
// Gateway type 0x7F is supported
if (type !== 0x7F) {
throw new Error(`${util_1.Util.toHexString(type)}: EEP type not supported`);
}
}
parse(telegram) {
const db0 = telegram.getDB(0);
if (this.manufacturerId !== EnoCore.Manufacturers.ELTAKO) {
throw new Error(`${EnoCore.Manufacturers[this.manufacturerId]}: manufacturer unhandled. Expected Eltako`);
}
// Manufacturer Specific Applications (EEP A5-3F-7F)
// Not for Eltako FRM60 https://www.google.de/search?q=eltako+FRM60
// [Eltako shutter TF61J-230V](https://www.google.de/search?q=eltako+TF61J-230V)
const eep = super.parseBase(telegram);
switch (telegram.rorg) {
case EnoCore.RORGs.FOURBS:
{
//const db0 = telegram.getDB(0); // 0x0A not blocked, 0x0E blocked
const db1 = telegram.getDB(1);
const db2 = telegram.getDB(2);
const db3 = telegram.getDB(3);
const sign = (db1 === 0x01) ? 1 : (db1 === 0x02) ? -1 : 0;
const time_ms = (db3 << 8 | db2) * 100 * sign;
eep.values.state = 'stopped';
eep.values.stoppedAfter_s = time_ms / 1000;
}
break;
case EnoCore.RORGs.RPS:
{
eep.values.state = this._stateMap[db0];
}
break;
default:
console.log(`${this.constructor.name}: `, telegram.toString());
}
return eep;
}
toString(values) {
const type = this.eepType.toString(16).padStart(2, '0').toUpperCase();
let msg = `${this.constructor.name}-${type}: state=${values.state}`;
if (values.stoppedAfter_s) {
msg += ` after ${values.stoppedAfter_s.toFixed(1)} s`;
}
return msg;
}
}
exports.EepParser_A5_3F_7F_Eltako = EepParser_A5_3F_7F_Eltako;
//# sourceMappingURL=EepParser_A5_3F_7F_Eltako.js.map