From 04e4a08ac91460b026f0d52b7cda5c70f6ec51a1 Mon Sep 17 00:00:00 2001 From: Gianmarco Pettinato Date: Mon, 29 Jan 2024 14:32:54 +0100 Subject: [PATCH] fixup! fixup! adding ha addon support --- matter-bridge/src/home-assistant/HAmiddleware.ts | 7 ------- matter-bridge/src/index.ts | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/matter-bridge/src/home-assistant/HAmiddleware.ts b/matter-bridge/src/home-assistant/HAmiddleware.ts index d69afa2..eb42dce 100644 --- a/matter-bridge/src/home-assistant/HAmiddleware.ts +++ b/matter-bridge/src/home-assistant/HAmiddleware.ts @@ -8,7 +8,6 @@ export class HAMiddleware { private logger = new Logger('HAMiddleware'); private hassClient: HassApi; private static instance: HAMiddleware; - private connectionOpen: boolean = false; private requestFulfilled: boolean = true; private entities: { [k: string]: HassEntity } = {}; private functionsToCallOnChange: { @@ -96,12 +95,6 @@ export class HAMiddleware { if (!HAMiddleware.instance) { const client = await hass(callerOptions); HAMiddleware.instance = new HAMiddleware(client); - let waited = 0; - const timeOut = 5000; - while (!HAMiddleware.instance.connectionOpen && waited < timeOut) { - await sleep(1000); - waited += 1000; - } } return HAMiddleware.instance; } diff --git a/matter-bridge/src/index.ts b/matter-bridge/src/index.ts index 2598245..ac99202 100644 --- a/matter-bridge/src/index.ts +++ b/matter-bridge/src/index.ts @@ -9,6 +9,7 @@ let HA_MIDDLEWARE: HAMiddleware; let BRIDGE: Bridge; async function run() { + LOGGER.info('Startup ...'); const token = getParameter('SUPERVISOR_TOKEN'); if (!token) { throw new Error('Missing auth token cannot run without it'); @@ -19,14 +20,18 @@ async function run() { path: '/core/websocket', token, }); + LOGGER.info('Connected to home assistant'); BRIDGE = getBridge(); + LOGGER.info('Creating the bridge'); await addAllDevicesToBridge(HA_MIDDLEWARE, BRIDGE); + LOGGER.info('all devices added'); BRIDGE.start(); } run() .then() .catch((error) => { + console.error(error); LOGGER.error(JSON.stringify(error)); });