@pst-on-npm/homebridge-enocean
Version:
Integrate EnOcean® devices into Homebridge.
127 lines • 5.53 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_D1_Eltako = void 0;
const EnoCore = __importStar(require("enocean-core"));
const EepParser_1 = require("./EepParser");
const util_1 = require("../util");
const DeviceConfig_1 = require("../homebridge/DeviceConfig");
/*
* D1: Manufacturer Specific Communication
* RORG D1 MSC Telegram
*/
class EepParser_D1_Eltako extends EepParser_1.EepParser {
_eltakoMessageCmdMap = {
'030301': 'start', // 'teach-in start',
'030302': 'start', // 'teach-in start',
'030300': 'stop', // 'teach-in end',
'030400': 'pass', // 'teach-in ID learned',
'FC0100': 'fail', // 'teach-in ID failed/rejected',
};
// See https://github.com/Jey-Cee/ioBroker.enocean/blob/master/lib/definitions/eltako.js
// and https://github.com/Jey-Cee/ioBroker.enocean/blob/7a623c622a67ec6f723822940570dc0b36883ab2/lib/tools/Packet_handler.js#L1259
_eltakoDeviceMap = {
// The 3E8 (TF61L) replies with 4BS '9E2D0708'-'00' which is the D3-D1 = <localId>
// w/o the highest octet 'FF' and D0 = 08 = data message (no teach-in but data)
// They all use the teach-in telegram 'E0400D80' to be send to them
'000003E8': { model: 'TF61L-230V', eep: 'A5-38-08' }, // Light (gateway)
'000003EC': { model: 'TF61J-230V', eep: 'A5-3F-7F' }, // Blinds
'00000402': { model: 'TF61J-230V', eep: 'A5-3F-7F' }, // Blinds
'00000414': { model: 'TF100L', eep: 'A5-38-08' }, // Socket/Light (gateway), not all TF100L support 4BS teach-in
'00000429': { model: 'FLD61', eep: 'A5-3F-7F' }, // LED PWM DIM
'0000046F': { model: 'FJ62NP-230V', eep: 'A5-3F-7F' }, // Blinds
};
/**
* Initializes an instance of EepParser_D1
* @param type the EEP type
*/
constructor(type = 0) {
super(type);
}
parse(telegram) {
const eep = super.parseBase(telegram);
if (telegram.rorg !== EnoCore.RORGs.MSC) {
return eep;
}
eep.values.msc = {};
const data = telegram.userData.toString('hex').toUpperCase();
const manufacturerId = parseInt(data.substring(0, 3), 16);
if (manufacturerId === EnoCore.Manufacturers.ELTAKO) {
switch (data.substring(4, 6)) {
case 'FE':
{
const msg = data.substring(6, 12).toUpperCase();
eep.values.eltakoMsc = { teachInStatus: this._eltakoMessageCmdMap[msg] };
}
break;
case 'FF':
{
const msg = data.substring(6, 14).toUpperCase();
const dev = this._eltakoDeviceMap[msg];
if (dev !== undefined) {
eep.values.msc.config = new DeviceConfig_1.DeviceConfig(telegram.sender.toString(), dev.eep, undefined, EnoCore.Manufacturers[manufacturerId], dev.model);
// Create a temporary name for the device
eep.values.msc.config.name = `${dev.model} ${util_1.Util.getTimeAsFourDigitString()}`;
}
}
break;
}
}
eep.values.msc.data = data;
eep.values.msc.manufacturerId = manufacturerId;
eep.values.msc.manufacturer = EnoCore.Manufacturers[manufacturerId];
return eep;
}
toString(data) {
let message = 'MSC';
if (data !== undefined) {
if (data.msc?.data) {
message += ` '${data.msc?.data}'`;
}
if (data.msc?.manufacturer) {
message += ` (${data.msc?.manufacturer})`;
}
if (data.eltakoMsc?.teachInStatus) {
message += ` teach-in ${data.eltakoMsc.teachInStatus}`;
}
if (data.msc?.config) {
message += ` ${JSON.stringify(data.msc.config)}`;
}
}
return message;
}
}
exports.EepParser_D1_Eltako = EepParser_D1_Eltako;
//# sourceMappingURL=EepParser_D1_Eltako.js.map