Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 as ArrayBuffer);
this.emit("voice_message", { wsId, data });
return;
}
await this.#messageReceived(wsId, message.toString());
});

Expand Down Expand Up @@ -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<string, unknown>;
}): Promise<void> {
await this.#broadcastEvent("assistant_event", event, api.EventCategory.Entity);
}

public async generateOauth2AuthUrl(state?: Record<string, unknown>): Promise<{ auth_url: string }> {
const conn = this.#getCoreClient();
if (!conn) {
Expand Down