From cdfd2976b3a55669069d7858ad1370edabf43dbe Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 31 Mar 2022 11:07:18 -0700 Subject: [PATCH] google-home: add types --- plugins/google-home/local-sdk-app/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/google-home/local-sdk-app/index.ts b/plugins/google-home/local-sdk-app/index.ts index 98048d531..20cd43eba 100644 --- a/plugins/google-home/local-sdk-app/index.ts +++ b/plugins/google-home/local-sdk-app/index.ts @@ -1,11 +1,13 @@ /// +import { IntentFlow } from "@google/local-home-sdk"; + const app = new smarthome.App("1.0.0"); -const SCRYPTED_INSECURE_PORT = 11080; +let SCRYPTED_INSECURE_PORT = 11080; app - .onIdentify(async (request) => { + .onIdentify(async (request: IntentFlow.IdentifyRequest) => { console.debug("IDENTIFY request:", request); const device = request.inputs[0].payload.device; @@ -14,11 +16,13 @@ app throw Error("mdns type not 'scrypted-gh'"); } + SCRYPTED_INSECURE_PORT = parseInt(request.inputs[0].payload.device.mdnsScanData!.txt.port); + // Decode scan data to obtain metadata about local device const proxyDeviceId = "local-hub-id"; // Return a response - const response = { + const response: IntentFlow.IdentifyResponse = { intent: smarthome.Intents.IDENTIFY, requestId: request.requestId, payload: { @@ -41,7 +45,7 @@ app .filter(device => device.verificationId !== 'local-hub-id'); // Return a response - const response = { + const response: IntentFlow.ReachableDevicesResponse = { intent: smarthome.Intents.REACHABLE_DEVICES, requestId: request.requestId, payload: {