@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
35 lines • 1.38 kB
JavaScript
import { writeDebugFile } from '../ISY.js';
import { ISYDeviceNode } from './ISYDeviceNode.js';
export class DynamicNode extends ISYDeviceNode {
nodeTypeId;
async applyNodeDef(nodeDef) {
if (!nodeDef) {
nodeDef = await this.getNodeDef(this.address);
if (this.isy.isDebugEnabled)
await writeDebugFile(JSON.stringify(nodeDef), `${this.address}_NodeDef.json`, this.isy.logger, this.isy.storagePath);
}
for (let st in this.drivers) {
if (!nodeDef?.sts?.st?.find((s) => s.id === st)) {
this.logger(`Driver ${this.drivers[st].name} ${st} not found in nodeDef. Removing...`);
delete this.drivers[st];
}
}
for (let cmd in this.commands) {
if (!nodeDef?.cmds?.accepts?.cmd?.find((c) => c.id === cmd)) {
try {
//@ts-ignore
this.logger(`Command ${this.commands[cmd]?.name} (${cmd}) not found in nodeDef. Removing...`);
delete this.commands[cmd];
}
catch {
this.logger(`Error removing command ${cmd}`);
}
}
}
}
constructor(isy, node, nodeDef) {
super(isy, node);
this.nodeTypeId = node.nodeTypeId;
}
}
//# sourceMappingURL=DynamicNode.js.map