Google Tasks
The Google Tasks integration allows you to connect your Google Tasks
You can use to-do lists in automations, such as adding a new task when Home Assistant detects a device has low batteries. When you combine with a Home Assistant voice assistant, you can manage your Google Tasks by saying something like Add clean out garage to personal task list.
Prerequisites
You need to configure developer credentials to allow Home Assistant to access your Google Account. These credentials are the same as the ones for Nest, Google Mail, and most other Google integrations. These are not the same as Device Auth credentials previously recommended for Google Calendar.
情景 1:您已经拥有凭据
在这种情况下,您需要做的就是启用 API:
- 转到 Google 开发者控制台 Google Tasks API
。 - 确认项目并 启用 API。
- 按照 配置 部分中描述的步骤继续进行。
情景 2:您尚未设置凭据
在这种情况下,您需要先生成一个客户端密钥:
生成客户端 ID 和客户端密钥
本节说明如何在 Google 开发者控制台
- 首先,转到 Google 开发者控制台以启用 Google Tasks API
。 - 选择 创建项目,输入项目名称并选择 创建。
- 启用 Google Tasks API。
- 导航到 API 和服务(左侧边栏) > 凭据
。 - 在左侧边栏,选择 OAuth 同意屏幕。
- 选择 外部 并 创建。
- 将 应用名称(请求同意的应用程序名称)设置为您想要的任何名称,例如 Home Assistant。
- 您需要选择一个 支持电子邮件。
- 从下拉菜单中选择您的电子邮件地址。
- 在 开发者联系信息 下,输入您的电子邮件地址(可以与上面的相同)。
- 向下滚动并选择 保存并继续。
- 您不需要在这里填写其他任何内容。添加此页面的其他信息(如应用标志)可能会触发 Google 的额外审核过程,并导致设置延迟几天。
- 然后,您将自动进入 范围 页面。
- 您不需要在此处添加任何范围。选择 保存并继续 以移至 测试用户 页面。
- 您不需要在 测试用户 页面添加任何内容。选择 保存并继续,这将带您到 摘要 页面。
- 选择 返回仪表板。
- 重新选择 OAuth 同意屏幕 并在 发布状态 下选择 发布应用。
- 否则您的凭据将每7天到期。
- 确保 发布状态 设置为 在生产中。
- 在左侧边栏中,选择 凭据,然后选择 创建凭据(在屏幕顶部),再选择 OAuth 客户端 ID。
- 将 应用程序类型 设置为 Web 应用程序,并给这个凭据集命名(例如 “Home Assistant Credentials”)。
- 将
https://my.home-assistant.io/redirect/oauth
添加到 授权重定向 URI 中,然后选择 创建。- 这不是占位符。它是必须使用的 URI。
- 然后,您将看到一个弹出窗口,显示 OAuth 客户端已创建,显示 您的客户端 ID 和 您的客户端密钥。
- 请记下这些(例如,将其复制并粘贴到文本编辑器中),因为您稍后需要它们。
- 记下这些字符串后,选择 确定。
- 如果您在任何时候需要再次查找这些凭据,请导航到 API 和服务 > 凭据,您将在 OAuth 2.0 客户端 ID 下看到 Home Assistant Credentials(或您在上一步中命名的任何名称)。
- 要查看 客户端 ID 和 客户端密钥,请选择铅笔图标。这将带您进入这些凭据的设置页面,信息将在页面右侧显示。
- 恭喜您!您现在是客户端密钥的保管者。将其保存在您的宝藏箱中。在大多数情况下,您的新凭据将在几分钟内激活。然而,Google 表示在某些情况下激活可能需要多达五小时。
配置
要将 Google Tasks integration 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在右下角,选择
Add Integration 按钮。 -
从列表中选择 Google Tasks。
-
按照屏幕上的说明完成设置。
集成设置将接下来给您提供进入 应用凭证(OAuth 客户端 ID 和客户端密钥)的说明,并授权 Home Assistant 连接到 Google Tasks。
OAuth 和设备授权步骤
-
继续执行选择您想要授权的帐户的步骤。
-
注意:您可能会收到一条消息,告知您该应用尚未经过验证,您需要确认才能继续。
-
现在您可以看到您授权 Home Assistant 访问的详细信息,底部有两个选项。选择 继续。
-
页面现在将显示 将账户链接到 Home Assistant 吗?,请注意 您的实例 URL。如果不正确,请参考 我的 Home Assistant。如果一切正常,请选择 链接账户。
-
您可以关闭窗口,然后返回 Home Assistant,在那里您应该会看到来自 Home Assistant 的 成功! 消息。
Supported functionality
Entities
The Google Tasks integration provides the following entities.
To-do lists
The integration will create a to-do list entity for every task list. For example, a Google Tasks list named My Tasks then will have a Home Assistant to-do list entity named My Tasks.
The Google Task integration can create, update, or delete items on a to-do list. The to-do list entities support creating, updating, and deleting items on the to-do list. A to-do list item supports the following fields:
- Item: The item is the Google Task Title field.
- Due date: The Google Tasks Date. The time field in Google Tasks is not supported by the Google Tasks API.
- Description: The Google Tasks Details field.
-
Status: The Google Tasks Completed check box corresponds to the to-do list
status
needs_action
when not checked andcompleted
when checked.
Actions
The Google Tasks integration provides all actions supported by a to-do list entity including actions for retrieving, creating, updating, and deleting to-do list items and the fields described above. See the To-do list: Actions documentation for more details.
Examples
Low Battery Maintenance
You can use Google Tasks to help you automate battery maintenance. To tackle this you can use this blueprint to send a notification with devices that have low low battery level. The notification includes a button that can add an item to your Google Tasks to-do list.
Low Battery Notifications & Actions
Data updates
The Google Tasks integration fetches task lists once initially, and creates a to-do list for each task list. Data for each to-do list refreshed refreshed by polling数据轮询是定期查询设备或服务以检查更新或检索数据的过程。通过定义自定义轮询间隔,您可以控制系统检查新数据的频率,这有助于优化性能并减少不必要的网络流量。 [Learn more] every 30 minutes.
Updates to the to-do list in Home Assistant use the Google Tasks API and changes are reflected immediately in Google Tasks. This will also refresh the to-do list contents, polling数据轮询是定期查询设备或服务以检查更新或检索数据的过程。通过定义自定义轮询间隔,您可以控制系统检查新数据的频率,这有助于优化性能并减少不必要的网络流量。 [Learn more] again for any new changes.
Known limitations
There are some known Google Tasks API limitations that affect this integration:
- Only supports polling数据轮询是定期查询设备或服务以检查更新或检索数据的过程。通过定义自定义轮询间隔,您可以控制系统检查新数据的频率,这有助于优化性能并减少不必要的网络流量。 [Learn more]. Updates in Google Tasks are not reflected immediately in Home Assistant.
- Only supports viewing or setting a task due date. A task due time is not supported.
Troubleshooting
Can’t setup the integration
Symptom: “The OAuth client was not found.”
When trying to configure the integration, the Google OAuth flows shows the message The OAuth client was not found and Error 401: invalid_client.
Description
This means that the application credentials in Home Assistant do not match the OAuth credentials in the Google Cloud console.
Resolution
To resolve this issue:
- Follow the instructions in Application Credentials to remove any existing credentials.
- Follow the steps above in the Prerequisites.
- Follow the steps above in the Configuration.
Symptom: “Unable to access the Google API: Tasks API has not been used in project before or it is disabled”
Home Assistant fails to configure the integration with the error Unable to access the Google API: Google Tasks API has not been used in project before or it is disabled.
Description
This means that Home Assistant is unable to use the Google Tasks API because it was not enabled in the Google Cloud Console.
Resolution
Follow the steps above in the Prerequisites to enable the Google Tasks API.
Removing the integration
This integration follows standard integration removal. No extra steps are required.
从Home Assistant中移除集成实例
- 前往 设置 > 设备与服务 并选择集成卡片。
- 从设备列表中,选择要删除的集成实例。
- 在条目旁边,选择三个点
菜单。然后,选择 删除。
You will be asked if you would like to remove Application Credentials which you can do if you no longer plan to use Google Tasks with Home Assistant. You may want to also remove any credentials in the Google Cloud Console, created above in the Prerequisites, if they are no longer in use with any of your other Home Assistant integrations.