mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-16 13:56:53 +00:00
Update google_assistant JavaScript to support local query. Remove onP… (#21491)
This commit is contained in:
parent
e7c74db9d3
commit
2ac836aa26
@ -113,12 +113,16 @@ If you want to support active reporting of state to Google's server (configurati
|
|||||||
2. Click `Develop` on the top of the page, then click `Actions` located in the hamburger menu on the top left.
|
2. Click `Develop` on the top of the page, then click `Actions` located in the hamburger menu on the top left.
|
||||||
3. Upload [this Javascript file](/assets/integrations/google_assistant/app.js) for both Node and Chrome by clicking the `Upload Javascript files` button.
|
3. Upload [this Javascript file](/assets/integrations/google_assistant/app.js) for both Node and Chrome by clicking the `Upload Javascript files` button.
|
||||||
4. Add device scan configuration:
|
4. Add device scan configuration:
|
||||||
1. Click `+ New scan config`
|
1. Click `+ New scan config`
|
||||||
2. Select `MDNS`
|
2. Select `MDNS`
|
||||||
3. set mDNS service name to `_home-assistant._tcp.local`
|
3. Set mDNS service name to `_home-assistant._tcp.local`
|
||||||
5. `Save` your changes.
|
4. Click `Add field`, then under `Select a field` select `name`
|
||||||
6. Either wait for 30 minutes, or restart your connected Google device.
|
5. Enter a new `value` field set to `.*\._home-assistant\._tcp\.local`
|
||||||
7. Restart Home Assistant Core.
|
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)
|
You can debug the setup by following [these instructions](https://developers.google.com/assistant/smarthome/develop/local#debugging_from_chrome)
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ const reachableDevicesHandler = async (request) => {
|
|||||||
console.log("REACHABLE_DEVICES intent:", request);
|
console.log("REACHABLE_DEVICES intent:", request);
|
||||||
const hassCustomData = findHassCustomDeviceDataByDeviceId(request.requestId, request.devices, request.inputs[0].payload.device.id);
|
const hassCustomData = findHassCustomDeviceDataByDeviceId(request.requestId, request.devices, request.inputs[0].payload.device.id);
|
||||||
try {
|
try {
|
||||||
return forwardRequest(hassCustomData,
|
return forwardRequest(hassCustomData,
|
||||||
// Old code would sent it to the proxy ID: hassCustomData.proxyDeviceId
|
// Old code would sent it to the proxy ID: hassCustomData.proxyDeviceId
|
||||||
// But tutorial claims otherwise, but maybe it is not for hub devices??
|
// But tutorial claims otherwise, but maybe it is not for hub devices??
|
||||||
// https://developers.google.com/assistant/smarthome/develop/local#implement_the_execute_handler
|
// https://developers.google.com/assistant/smarthome/develop/local#implement_the_execute_handler
|
||||||
@ -155,19 +155,25 @@ const executeHandler = async (request) => {
|
|||||||
throw err;
|
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
|
app
|
||||||
.onIdentify(identifyHandler)
|
.onIdentify(identifyHandler)
|
||||||
.onReachableDevices(reachableDevicesHandler)
|
.onReachableDevices(reachableDevicesHandler)
|
||||||
.onExecute(executeHandler)
|
.onExecute(executeHandler)
|
||||||
// Undocumented in TypeScript
|
.onQuery(queryHandler)
|
||||||
// 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, {});
|
|
||||||
})
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.onIndicate((req) => console.log("Indicate", req))
|
.onIndicate((req) => console.log("Indicate", req))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -175,8 +181,6 @@ app
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.onProvision((req) => console.log("Provision", req))
|
.onProvision((req) => console.log("Provision", req))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.onQuery((req) => console.log("Query", req))
|
|
||||||
// @ts-ignore
|
|
||||||
.onRegister((req) => console.log("Register", req))
|
.onRegister((req) => console.log("Register", req))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.onUnprovision((req) => console.log("Unprovision", req))
|
.onUnprovision((req) => console.log("Unprovision", req))
|
||||||
@ -184,6 +188,6 @@ app
|
|||||||
.onUpdate((req) => console.log("Update", req))
|
.onUpdate((req) => console.log("Update", req))
|
||||||
.listen()
|
.listen()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Ready!");
|
console.log("Ready!");
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user