From 4bba9a6d861ba314fb12d328d42f0b29c78d5eb9 Mon Sep 17 00:00:00 2001 From: albaintor <118518828+albaintor@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:05:19 +0200 Subject: [PATCH 1/2] Add voice message handling and assistant events --- index.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 2c67362..9de42c9 100644 --- a/index.ts +++ b/index.ts @@ -181,7 +181,12 @@ class IntegrationAPI extends EventEmitter { this.#authentication(wsId, true); - connection.on("message", async (message) => { + connection.on("message", async (message, isBinary) => { + if (isBinary) { + const data = Array.isArray(message) ? Buffer.concat(message) : Buffer.from(message); + this.emit("voice_message", { wsId, data }); + return; + } await this.#messageReceived(wsId, message.toString()); }); @@ -1078,6 +1083,16 @@ class IntegrationAPI extends EventEmitter { return this.#configuredEntities.updateEntityAttributes(entityId, attributes); } + /** Broadcast a voice-assistant lifecycle event to connected Remote clients. */ + public async emitAssistantEvent(event: { + type: string; + entity_id: string; + session_id: number; + data?: Record; + }): Promise { + await this.#broadcastEvent("assistant_event", event, api.EventCategory.Entity); + } + public async generateOauth2AuthUrl(state?: Record): Promise<{ auth_url: string }> { const conn = this.#getCoreClient(); if (!conn) { From 67184fa240b516dfeb481e367a1135b129f7b61c Mon Sep 17 00:00:00 2001 From: albaintor <118518828+albaintor@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:16:45 +0200 Subject: [PATCH 2/2] Fix binary WebSocket message type handling --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 9de42c9..1896909 100644 --- a/index.ts +++ b/index.ts @@ -183,7 +183,7 @@ class IntegrationAPI extends EventEmitter { connection.on("message", async (message, isBinary) => { if (isBinary) { - const data = Array.isArray(message) ? Buffer.concat(message) : Buffer.from(message); + const data = Array.isArray(message) ? Buffer.concat(message) : Buffer.from(message as ArrayBuffer); this.emit("voice_message", { wsId, data }); return; }