From 37b0928bcc8383dced510bf4f99e72be91e56c2e Mon Sep 17 00:00:00 2001 From: tronikos Date: Fri, 2 Feb 2024 08:20:19 -0800 Subject: [PATCH] Google Assistant SDK: Document steps to enable personal results (#30472) * Google Assistant SDK: Document steps to enable personal results * Update google_assistant_sdk.markdown * Apply suggestions from code review Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> * Update google_assistant_sdk.markdown --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --- .../google_assistant_sdk.markdown | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/source/_integrations/google_assistant_sdk.markdown b/source/_integrations/google_assistant_sdk.markdown index 14f716ef07f..9de87d962a8 100644 --- a/source/_integrations/google_assistant_sdk.markdown +++ b/source/_integrations/google_assistant_sdk.markdown @@ -69,6 +69,60 @@ The integration setup will next give you instructions to enter the [Application {% enddetails %} +## Enable personal results (for advanced users) + +This guide shows you how to enable personal commands such as "remind me tomorrow at 9 pm to take out the trash". + +This guide is for advanced users only. It requires creating an OAuth client ID of the Desktop app, running a Python program on your desktop or laptop, copying the resulting credentials to your Home Assistant config files, and likely running an Android emulator. + + ### Prerequisites + +- Successfully installed the Google Assistant integration. + +{% details "Create credentials" %} + +1. Navigate to [Google Developers Console > Credentials](https://console.cloud.google.com/apis/credentials). +2. Select the project you created earlier from the dropdown menu in the upper left corner. +3. Select **Create credentials** (at the top of the screen), then select **OAuth client ID**. +4. Set the Application type to **Desktop app** and give this credential set a name (like "Home Assistant Desktop Credentials"). +5. Select **Create**. +6. In the OAuth client-created screen, select **Download JSON**. +7. Rename the downloaded file to `client_secret.json`. +8. On your Windows, Linux, or Mac machine, download Python if you don't have it already. +9. Open the terminal (on Windows, select **Start** and then type `cmd`). +10. In the terminal, run the following commands (preferably in a Python virtual environment): +11. `python -m pip install --upgrade google-auth-oauthlib[tool]` + - Under Windows: `google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype --scope https://www.googleapis.com/auth/gcm --save --client-secrets %userprofile%\Downloads\client_secret.json` + - Under Linux: `google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype --scope https://www.googleapis.com/auth/gcm --save --client-secrets ~/Downloads/client_secret.json` + - **Result**: A browser window will open, asking you to select the account to continue to the cloud project you created earlier. +12. Once you select the correct account, select both checkboxes: + - **Use your Google Assistant: broad access to your Google account** + - **Send information to your Android device** +13. Select **Continue**. + - **Result**: If everything was successful, you will get a **The authentication flow has completed. You may close this window** message in your browser. + - In your terminal you will see the path where the credentials were saved. For example: `credentials saved: C:\Users\user\AppData\Roaming\google-oauthlib-tool\credentials.json` +14. Open the `credentials.json` in a text editor. Keep it open since you will need to copy several values from it. +15. In the file editor of your Home Assistant, typically http://homeassistant.local:8123/core_configurator, open `/homeassistant/.storage/application_credentials`. + - Locate the entry for `google_assistant_sdk` and modify `client_id` and `client_secret` to match the ones from `credentials.json`. + - Save the file. +16. Open `/homeassistant/.storage/core.config_entries`. + - Locate the entry for `google_assistant_sdk` and modify `refresh_token` to match the one from `credentials.json`. + - Save the file. +17. Restart Home Assistant. + +{% enddetails %} + +{% details "Enable personal results" %} + +1. Go to **{% my developer_services title="Developer Tools > Services" %}** and issue a query that requires personal results, for example call `google_assistant_sdk.send_text_command` with `command: "what is my name"` +2. On your phone, you should receive a notification **Allow personal answers** **Allow Google Assistant to answer your questions about your calendar, trips, and more**. +3. DO NOT tap on **ALLOW** (it won't work until you enter a device name). Instead, tap on the notification text. +4. If the app doesn't open, you need to retry on a device running Android 12. If you don't have such a device, you can use an Android emulator. +5. Tap on **Device Name**, enter any device name (like Home Assistant), and tap on **OK**. +6. Only after having a non-empty device name, enable the checkbox next to **Personal results**. + +{% enddetails %} + ## Troubleshooting If you have an error with your credentials you can delete them in the [Application Credentials](/integrations/application_credentials/) user interface. @@ -82,7 +136,6 @@ The easiest way to check if the integration is working is to check [My Google Ac ## Limitations/known issues - Multiple Google accounts are not supported. -- Personal results are not supported yet since that requires creating an OAuth client ID of the Desktop app. - If you see the issued commands in [My Google Activity](https://myactivity.google.com/myactivity), the integration is working fine. If the commands don't have the expected outcome, don't open an issue in the Home Assistant Core project or the [underlying library](https://github.com/tronikos/gassist_text). You should instead report the issue directly to Google [here](https://github.com/googlesamples/assistant-sdk-python/issues). Examples of known Google Assistant API issues: - Media playback commands (other than play news, play podcast, play white noise, or play rain sounds) don't work. - Routines don't work.