[matter] Typescript ESLint modifications (#18743)

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
pull/18776/head
Dan Cunningham 2025-06-07 15:36:28 -07:00 committed by GitHub
parent 805072b3c7
commit a8fe05c70c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 1686 additions and 63 deletions

View File

@ -0,0 +1,88 @@
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import regexp from "eslint-plugin-regexp";
import { globalIgnores } from "eslint/config";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import ts from "typescript-eslint";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
globalIgnores([
"**/dist/**/*",
"**/build/**/*",
"**/forwards/**/*",
"**/bin/*",
"**/require/*",
"docs/**/*",
"**/.mocharc.cjs",
"eslint.config.mjs",
"webpack.config.js",
]),
js.configs.recommended,
...ts.configs.recommendedTypeChecked,
regexp.configs["flat/recommended"],
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",
parserOptions: {
projectService: [],
},
},
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-base-to-string": "off",
"no-constant-condition": [
"error",
{
checkLoops: false,
},
],
"@typescript-eslint/no-namespace": "off",
"no-inner-declarations": "off",
"no-case-declarations": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/no-this-alias": "off",
"import/default": "off",
"import/export": "off",
"import/no-named-as-default-member": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/unbound-method": "off",
"no-ex-assign": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"import/no-unresolved": "off",
"regexp/optimal-quantifier-concatenation": "off",
},
}
];

File diff suppressed because it is too large Load Diff

View File

@ -10,26 +10,37 @@
"start": "ts-node src/app.ts", "start": "ts-node src/app.ts",
"webpack": "webpack --mode production", "webpack": "webpack --mode production",
"webpack-dev": "webpack --mode development", "webpack-dev": "webpack --mode development",
"format": "prettier --write \"src/**/*.ts\"" "format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint",
"lint-fix": "eslint --fix"
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^1.2.8",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.24.0",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"@types/bn.js": "^5.1.5", "@types/bn.js": "^5.1.5",
"@types/node": "^20.9.0", "@types/node": "^20.9.0",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"@types/ws": "^8.5.10", "@types/ws": "^8.5.10",
"@types/yargs": "^17.0.32", "@types/yargs": "^17.0.32",
"eslint-plugin-node-import": "^1.0.5",
"eslint-plugin-regexp": "^2.7.0",
"globals": "^16.0.0",
"prettier": "^3.5.3",
"prettier-plugin-organize-imports": "^4.1.0",
"ts-loader": "^9.4.4", "ts-loader": "^9.4.4",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.2.2", "typescript": "^5.8.3",
"typescript-eslint": "^8.33.0",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4", "webpack-cli": "^5.1.4"
"prettier": "^3.5.3",
"prettier-plugin-organize-imports": "^4.1.0"
}, },
"dependencies": { "dependencies": {
"@matter/main": "v0.14.0-alpha.0-20250531-7ed2d6da8", "@matter/main": "v0.14.0-alpha.0-20250531-7ed2d6da8",
"@matter/node": "v0.14.0-alpha.0-20250531-7ed2d6da8", "@matter/node": "v0.14.0-alpha.0-20250531-7ed2d6da8",
"@project-chip/matter.js" : "v0.14.0-alpha.0-20250531-7ed2d6da8", "@project-chip/matter.js": "v0.14.0-alpha.0-20250531-7ed2d6da8",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"ws": "^8.18.0", "ws": "^8.18.0",
"yargs": "^17.7.2" "yargs": "^17.7.2"
@ -43,4 +54,4 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
} }
} }

View File

@ -18,7 +18,7 @@ export abstract class Controller {
/** /**
* Closes the controller * Closes the controller
*/ */
abstract close(): void; abstract close(): Promise<void>;
/** /**
* Returns the unique identifier of the controller * Returns the unique identifier of the controller

View File

@ -14,8 +14,8 @@ const logger = Logger.get("matter");
Logger.level = LogLevel.DEBUG; Logger.level = LogLevel.DEBUG;
Logger.format = LogFormat.PLAIN; Logger.format = LogFormat.PLAIN;
process.on("SIGINT", () => shutdownHandler("SIGINT")); process.on("SIGINT", () => void shutdownHandler("SIGINT"));
process.on("SIGTERM", () => shutdownHandler("SIGTERM")); process.on("SIGTERM", () => void shutdownHandler("SIGTERM"));
process.on("uncaughtException", function (err) { process.on("uncaughtException", function (err) {
logger.error(`Caught exception: ${err} ${err.stack}`); logger.error(`Caught exception: ${err} ${err.stack}`);
}); });
@ -79,7 +79,7 @@ export interface WebSocketSession extends WebSocket {
const socketPort = argv.port ? parseInt(argv.port) : 8888; const socketPort = argv.port ? parseInt(argv.port) : 8888;
const wss: Server = new WebSocket.Server({ port: socketPort, host: argv.host }); const wss: Server = new WebSocket.Server({ port: socketPort, host: argv.host });
wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => { wss.on("connection", (ws: WebSocketSession, req: IncomingMessage) => {
ws.sendResponse = (type: string, id: string, result?: any, error?: string) => { ws.sendResponse = (type: string, id: string, result?: any, error?: string) => {
const message: Message = { const message: Message = {
type: "response", type: "response",
@ -113,7 +113,11 @@ wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => {
ws.on("message", (message: string) => { ws.on("message", (message: string) => {
try { try {
const request: Request = JSON.parse(message); const request: Request = JSON.parse(message);
ws.controller?.handleRequest(request); if (ws.controller) {
void ws.controller.handleRequest(request).catch((error: Error) => {
ws.sendResponse(MessageType.ResultError, "", undefined, error.message);
});
}
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
ws.sendResponse(MessageType.ResultError, "", undefined, error.message); ws.sendResponse(MessageType.ResultError, "", undefined, error.message);
@ -121,10 +125,12 @@ wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => {
} }
}); });
ws.on("close", async () => { ws.on("close", () => {
logger.info("WebSocket closed"); logger.info("WebSocket closed");
if (ws.controller) { if (ws.controller) {
await ws.controller.close(); void ws.controller.close().catch((error: Error) => {
logger.error(`Error closing controller: ${error}`);
});
} }
}); });
@ -142,7 +148,7 @@ wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => {
const service = params.get("service") === "bridge" ? "bridge" : "client"; const service = params.get("service") === "bridge" ? "bridge" : "client";
if (service === "client") { if (service === "client") {
let controllerName = params.get("controllerName"); const controllerName = params.get("controllerName");
try { try {
if (controllerName == null) { if (controllerName == null) {
throw new Error("No controllerName parameter in the request"); throw new Error("No controllerName parameter in the request");
@ -154,7 +160,11 @@ wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => {
} }
}); });
ws.controller = new ClientController(ws, params); ws.controller = new ClientController(ws, params);
await ws.controller.init(); void ws.controller.init().catch(error => {
printError(logger, error, "ClientController.init()");
logger.error("returning error", error.message);
ws.close(1002, error.message);
});
} catch (error: any) { } catch (error: any) {
printError(logger, error, "ClientController.init()"); printError(logger, error, "ClientController.init()");
logger.error("returning error", error.message); logger.error("returning error", error.message);
@ -172,7 +182,11 @@ wss.on("connection", async (ws: WebSocketSession, req: IncomingMessage) => {
} }
}); });
ws.controller = new BridgeController(ws, params); ws.controller = new BridgeController(ws, params);
await ws.controller.init(); void ws.controller.init().catch(error => {
printError(logger, error, "BridgeController.init()");
logger.error("returning error", error.message);
ws.close(1002, error.message);
});
} catch (error: any) { } catch (error: any) {
printError(logger, error, "BridgeController.init()"); printError(logger, error, "BridgeController.init()");
logger.error("returning error", error.message); logger.error("returning error", error.message);

View File

@ -12,7 +12,7 @@ export class BridgeController extends Controller {
override params: URLSearchParams, override params: URLSearchParams,
) { ) {
super(ws, params); super(ws, params);
let storagePath = this.params.get("storagePath"); const storagePath = this.params.get("storagePath");
if (storagePath === null) { if (storagePath === null) {
throw new Error("No storagePath parameters in the request"); throw new Error("No storagePath parameters in the request");
@ -60,7 +60,7 @@ export class BridgeController extends Controller {
override async init() {} override async init() {}
executeCommand(namespace: string, functionName: string, args: any[]): any | Promise<any> { executeCommand(namespace: string, functionName: string, args: any[]): any | Promise<any> {
let baseObject: any = this.deviceNode; const baseObject: any = this.deviceNode;
logger.debug(`Executing function ${namespace}.${functionName}(${Logger.toJSON(args)})`); logger.debug(`Executing function ${namespace}.${functionName}(${Logger.toJSON(args)})`);

View File

@ -184,7 +184,7 @@ export class DeviceNode {
async setEndpointState(endpointId: string, clusterName: string, stateName: string, stateValue: any) { async setEndpointState(endpointId: string, clusterName: string, stateName: string, stateValue: any) {
const device = this.devices.get(endpointId); const device = this.devices.get(endpointId);
if (device) { if (device) {
device.updateState(clusterName, stateName, stateValue); void device.updateState(clusterName, stateName, stateValue);
} }
} }
@ -301,10 +301,6 @@ export class DeviceNode {
return (await this.storageService.open(DeviceNode.DEFAULT_NODE_ID)).createContext("openhab"); return (await this.storageService.open(DeviceNode.DEFAULT_NODE_ID)).createContext("openhab");
} }
async #rootStorage() {
return (await this.storageService.open(DeviceNode.DEFAULT_NODE_ID)).createContext("root");
}
async #uniqueIdForBridge() { async #uniqueIdForBridge() {
const rootContext = await this.#ohBridgeStorage(); const rootContext = await this.#ohBridgeStorage();
return rootContext.get("basicInformation.uniqueId", BasicInformationServer.createUniqueId()); return rootContext.get("basicInformation.uniqueId", BasicInformationServer.createUniqueId());

View File

@ -83,7 +83,7 @@ export class ColorDeviceType extends GenericDeviceType {
const parent = this; const parent = this;
return class extends ColorControlServer { return class extends ColorControlServer {
override async moveToColorTemperatureLogic(targetMireds: number, transitionTime: number) { override async moveToColorTemperatureLogic(targetMireds: number, transitionTime: number) {
await parent.sendBridgeEvent("colorControl", "colorTemperatureMireds", targetMireds); parent.sendBridgeEvent("colorControl", "colorTemperatureMireds", targetMireds);
return super.moveToColorTemperatureLogic(targetMireds, transitionTime); return super.moveToColorTemperatureLogic(targetMireds, transitionTime);
} }
@ -92,8 +92,8 @@ export class ColorDeviceType extends GenericDeviceType {
targetSaturation: number, targetSaturation: number,
transitionTime: number, transitionTime: number,
) { ) {
await parent.sendBridgeEvent("colorControl", "currentHue", targetHue); parent.sendBridgeEvent("colorControl", "currentHue", targetHue);
await parent.sendBridgeEvent("colorControl", "currentSaturation", targetSaturation); parent.sendBridgeEvent("colorControl", "currentSaturation", targetSaturation);
} }
}; };
} }

View File

@ -37,11 +37,11 @@ export class DoorLockDeviceType extends GenericDeviceType {
const parent = this; const parent = this;
return class extends DoorLockServer { return class extends DoorLockServer {
override async lockDoor() { override async lockDoor() {
await parent.sendBridgeEvent("doorLock", "lockState", LockState.Locked); parent.sendBridgeEvent("doorLock", "lockState", LockState.Locked);
} }
override async unlockDoor() { override async unlockDoor() {
await parent.sendBridgeEvent("doorLock", "lockState", LockState.Unlocked); parent.sendBridgeEvent("doorLock", "lockState", LockState.Unlocked);
} }
}; };
} }

View File

@ -83,13 +83,13 @@ export abstract class GenericDeviceType {
const parent = this; const parent = this;
return class extends OnOffType { return class extends OnOffType {
override async on() { override async on() {
await parent.sendBridgeEvent("onOff", "onOff", true); parent.sendBridgeEvent("onOff", "onOff", true);
if (setLocally) { if (setLocally) {
await super.on(); await super.on();
} }
} }
override async off() { override async off() {
await parent.sendBridgeEvent("onOff", "onOff", false); parent.sendBridgeEvent("onOff", "onOff", false);
if (setLocally) { if (setLocally) {
await super.off(); await super.off();
} }
@ -106,7 +106,7 @@ export abstract class GenericDeviceType {
withOnOff: boolean, withOnOff: boolean,
options: TypeFromPartialBitSchema<typeof LevelControl.Options>, options: TypeFromPartialBitSchema<typeof LevelControl.Options>,
) { ) {
await parent.sendBridgeEvent("levelControl", "currentLevel", level); parent.sendBridgeEvent("levelControl", "currentLevel", level);
} }
}; };
} }
@ -121,7 +121,7 @@ export abstract class GenericDeviceType {
#generateAttributes<T extends Record<string, any>, U extends Partial<T>>(defaults: T, overrides: U): T { #generateAttributes<T extends Record<string, any>, U extends Partial<T>>(defaults: T, overrides: U): T {
const alwaysAdd = ["fixedLabel"]; const alwaysAdd = ["fixedLabel"];
let entries = this.#mergeWithDefaults(defaults, overrides); const entries = this.#mergeWithDefaults(defaults, overrides);
// Ensure entries include the values from overrides for the keys in alwaysAdd // Ensure entries include the values from overrides for the keys in alwaysAdd
alwaysAdd.forEach(key => { alwaysAdd.forEach(key => {
if (key in overrides) { if (key in overrides) {

View File

@ -53,15 +53,11 @@ export class WindowCoveringDeviceType extends GenericDeviceType {
targetPercent100ths?: number, targetPercent100ths?: number,
): Promise<void> { ): Promise<void> {
if (targetPercent100ths != null) { if (targetPercent100ths != null) {
await parent.sendBridgeEvent( parent.sendBridgeEvent("windowCovering", "targetPositionLiftPercent100ths", targetPercent100ths);
"windowCovering",
"targetPositionLiftPercent100ths",
targetPercent100ths,
);
} }
} }
override async handleStopMovement() { override async handleStopMovement() {
await parent.sendBridgeEvent("windowCovering", "operationalStatus", { parent.sendBridgeEvent("windowCovering", "operationalStatus", {
global: WindowCovering.MovementStatus.Stopped, global: WindowCovering.MovementStatus.Stopped,
lift: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped,
tilt: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped,

View File

@ -23,8 +23,8 @@ export class ClientController extends Controller {
super(ws, params); super(ws, params);
const stringId = this.params.get("nodeId"); const stringId = this.params.get("nodeId");
const nodeId = stringId != null ? parseInt(stringId) : null; const nodeId = stringId != null ? parseInt(stringId) : null;
let storagePath = this.params.get("storagePath"); const storagePath = this.params.get("storagePath");
let controllerName = this.params.get("controllerName"); const controllerName = this.params.get("controllerName");
if (nodeId === null || storagePath === null || controllerName === null) { if (nodeId === null || storagePath === null || controllerName === null) {
throw new Error("Missing required parameters in the request"); throw new Error("Missing required parameters in the request");
@ -53,16 +53,15 @@ export class ClientController extends Controller {
} }
executeCommand(namespace: string, functionName: string, args: any[]): any | Promise<any> { executeCommand(namespace: string, functionName: string, args: any[]): any | Promise<any> {
const controllerAny: any = this;
let baseObject: any;
logger.debug(`Executing function ${namespace}.${functionName}(${Logger.toJSON(args)})`); logger.debug(`Executing function ${namespace}.${functionName}(${Logger.toJSON(args)})`);
const controllerAny: any = this;
if (typeof controllerAny[namespace] !== "object") { if (typeof controllerAny[namespace] !== "object") {
throw new Error(`Namespace ${namespace} not found`); throw new Error(`Namespace ${namespace} not found`);
} }
baseObject = controllerAny[namespace]; const baseObject = controllerAny[namespace];
if (typeof baseObject[functionName] !== "function") { if (typeof baseObject[functionName] !== "function") {
throw new Error(`Function ${functionName} not found`); throw new Error(`Function ${functionName} not found`);
} }

View File

@ -29,7 +29,7 @@ export class Clusters {
*/ */
async command(nodeId: number, endpointId: number, clusterName: string, commandName: string, args: any) { async command(nodeId: number, endpointId: number, clusterName: string, commandName: string, args: any) {
logger.debug(`command ${nodeId} ${endpointId} ${clusterName} ${commandName} ${Logger.toJSON(args)}`); logger.debug(`command ${nodeId} ${endpointId} ${clusterName} ${commandName} ${Logger.toJSON(args)}`);
const device = await this.controllerNode.getNode(nodeId).getDeviceById(endpointId); const device = this.controllerNode.getNode(nodeId).getDeviceById(endpointId);
if (device == undefined) { if (device == undefined) {
throw new Error(`Endpoint ${endpointId} not found`); throw new Error(`Endpoint ${endpointId} not found`);
} }
@ -84,7 +84,7 @@ export class Clusters {
} }
} }
const device = await this.controllerNode.getNode(nodeId).getDeviceById(endpointId); const device = this.controllerNode.getNode(nodeId).getDeviceById(endpointId);
if (device == undefined) { if (device == undefined) {
throw new Error(`Endpoint ${endpointId} not found`); throw new Error(`Endpoint ${endpointId} not found`);
} }
@ -135,7 +135,7 @@ export class Clusters {
* @param attributeName * @param attributeName
*/ */
async readAttribute(nodeId: number, endpointId: number, clusterName: string, attributeName: string) { async readAttribute(nodeId: number, endpointId: number, clusterName: string, attributeName: string) {
const device = await this.controllerNode.getNode(nodeId).getDeviceById(endpointId); const device = this.controllerNode.getNode(nodeId).getDeviceById(endpointId);
if (device == undefined) { if (device == undefined) {
throw new Error(`Endpoint ${endpointId} not found`); throw new Error(`Endpoint ${endpointId} not found`);
} }
@ -171,7 +171,7 @@ export class Clusters {
* @returns * @returns
*/ */
async readCluster(nodeId: string | number, endpointId: number, clusterNameOrId: string | number) { async readCluster(nodeId: string | number, endpointId: number, clusterNameOrId: string | number) {
const device = await this.controllerNode.getNode(nodeId).getDeviceById(endpointId); const device = this.controllerNode.getNode(nodeId).getDeviceById(endpointId);
if (device === undefined) { if (device === undefined) {
throw new Error(`Endpoint ${endpointId} not found`); throw new Error(`Endpoint ${endpointId} not found`);
} }

View File

@ -39,7 +39,7 @@ export class Nodes {
* @returns * @returns
*/ */
async requestAllData(nodeId: string | number) { async requestAllData(nodeId: string | number) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
if (node.initialized) { if (node.initialized) {
return this.controllerNode.sendSerializedNode(node); return this.controllerNode.sendSerializedNode(node);
} else { } else {
@ -54,7 +54,7 @@ export class Nodes {
* @returns * @returns
*/ */
async requestEndpointData(nodeId: string | number, endpointId: number) { async requestEndpointData(nodeId: string | number, endpointId: number) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
if (node.initialized) { if (node.initialized) {
return this.controllerNode.sendSerializedNode(node, endpointId); return this.controllerNode.sendSerializedNode(node, endpointId);
} else { } else {
@ -79,7 +79,7 @@ export class Nodes {
let ipPort: number | undefined; let ipPort: number | undefined;
let ip: string | undefined; let ip: string | undefined;
let instanceId: string | undefined; let instanceId: string | undefined;
let ble = false; const ble = false;
if (typeof pairingCode === "string" && pairingCode.trim().length > 0) { if (typeof pairingCode === "string" && pairingCode.trim().length > 0) {
pairingCode = pairingCode.trim(); pairingCode = pairingCode.trim();
@ -161,7 +161,7 @@ export class Nodes {
* @param nodeId * @param nodeId
*/ */
async reconnectNode(nodeId: number | string) { async reconnectNode(nodeId: number | string) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
node.triggerReconnect(); node.triggerReconnect();
} }
@ -171,7 +171,7 @@ export class Nodes {
* @returns * @returns
*/ */
async getFabrics(nodeId: number | string) { async getFabrics(nodeId: number | string) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
const operationalCredentialsCluster = node.getRootClusterClient(OperationalCredentialsCluster); const operationalCredentialsCluster = node.getRootClusterClient(OperationalCredentialsCluster);
if (operationalCredentialsCluster === undefined) { if (operationalCredentialsCluster === undefined) {
throw new Error(`OperationalCredentialsCluster for node ${nodeId} not found.`); throw new Error(`OperationalCredentialsCluster for node ${nodeId} not found.`);
@ -191,7 +191,7 @@ export class Nodes {
return; return;
} }
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
if (node === undefined) { if (node === undefined) {
throw new Error(`Node ${nodeId} not found`); throw new Error(`Node ${nodeId} not found`);
} }
@ -233,7 +233,7 @@ export class Nodes {
* @param timeout * @param timeout
*/ */
async basicCommissioningWindow(nodeId: number | string, timeout = 900) { async basicCommissioningWindow(nodeId: number | string, timeout = 900) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
await node.openBasicCommissioningWindow(timeout); await node.openBasicCommissioningWindow(timeout);
console.log(`Basic Commissioning Window for node ${nodeId} opened`); console.log(`Basic Commissioning Window for node ${nodeId} opened`);
} }
@ -245,7 +245,7 @@ export class Nodes {
* @returns * @returns
*/ */
async enhancedCommissioningWindow(nodeId: number | string, timeout = 900) { async enhancedCommissioningWindow(nodeId: number | string, timeout = 900) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
const data = await node.openEnhancedCommissioningWindow(timeout); const data = await node.openEnhancedCommissioningWindow(timeout);
console.log(`Enhanced Commissioning Window for node ${nodeId} opened`); console.log(`Enhanced Commissioning Window for node ${nodeId} opened`);
@ -262,7 +262,7 @@ export class Nodes {
* @param nodeId * @param nodeId
*/ */
async logNode(nodeId: number | string) { async logNode(nodeId: number | string) {
const node = await this.controllerNode.getNode(nodeId); const node = this.controllerNode.getNode(nodeId);
console.log("Logging structure of Node ", node.nodeId.toString()); console.log("Logging structure of Node ", node.nodeId.toString());
node.logStructure(); node.logStructure();
} }

View File

@ -1,6 +1,6 @@
import { Logger } from "@matter/general"; import { Logger } from "@matter/general";
export function printError(logger: Logger, error: Error, functionName: String) { export function printError(logger: Logger, error: Error, functionName: string) {
logger.error(`Error executing function ${functionName}: ${error.message}`); logger.error(`Error executing function ${functionName}: ${error.message}`);
logger.error(`Stack trace: ${error.stack}`); logger.error(`Stack trace: ${error.stack}`);