Update google_assistant JavaScript to support local query. Remove onP… (#21491)

This commit is contained in:
Marcus 2022-02-14 23:22:48 -08:00 committed by GitHub
parent e7c74db9d3
commit 2ac836aa26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 20 deletions

View File

@ -115,10 +115,14 @@ If you want to support active reporting of state to Google's server (configurati
4. Add device scan configuration:
1. Click `+ New scan config`
2. Select `MDNS`
3. set mDNS service name to `_home-assistant._tcp.local`
5. `Save` your changes.
6. Either wait for 30 minutes, or restart your connected Google device.
7. Restart Home Assistant Core.
3. Set mDNS service name to `_home-assistant._tcp.local`
4. Click `Add field`, then under `Select a field` select `name`
5. Enter a new `value` field set to `.*\._home-assistant\._tcp\.local`
5. Check the box `Support local query` under `Add capabilities`.
6. `Save` your changes.
7. Either wait for 30 minutes, or restart your connected Google device.
8. Restart Home Assistant Core.
9. With a Google Assistant device, try saying "OK Google, sync my devices." This can be helpful to avoid issues, especially if you are enabling local fulfillment sometime after adding cloud Google Assistant support.
You can debug the setup by following [these instructions](https://developers.google.com/assistant/smarthome/develop/local#debugging_from_chrome)

View File

@ -155,19 +155,25 @@ const executeHandler = async (request) => {
throw err;
}
};
const app = new App("1.0.0");
const queryHandler = async (request) => {
console.log("QUERY intent:", request);
const device = request.inputs[0].payload.devices[0];
try {
return await forwardRequest(device.customData, device.id, request);
} catch (err) {
if (err instanceof UnknownInstance) {
err.throwHandlerError();
}
throw err;
}
};
const app = new App("1.1.0");
app
.onIdentify(identifyHandler)
.onReachableDevices(reachableDevicesHandler)
.onExecute(executeHandler)
// Undocumented in TypeScript
// Suggested by Googler, seems to work :shrug:
// https://github.com/actions-on-google/smart-home-local/issues/1#issuecomment-515706997
// @ts-ignore
.onProxySelected((req) => {
console.log("ProxySelected", req);
return createResponse(req, {});
})
.onQuery(queryHandler)
// @ts-ignore
.onIndicate((req) => console.log("Indicate", req))
// @ts-ignore
@ -175,8 +181,6 @@ app
// @ts-ignore
.onProvision((req) => console.log("Provision", req))
// @ts-ignore
.onQuery((req) => console.log("Query", req))
// @ts-ignore
.onRegister((req) => console.log("Register", req))
// @ts-ignore
.onUnprovision((req) => console.log("Unprovision", req))