Google Mail
Google Mail 集成允许您将 Google Mail 连接到 Home Assistant。该集成添加了一个动作,允许您设置电子邮件自动回复,用于度假时。还添加了一个 notify 动作,允许您起草或发送纯文本电子邮件。
前提条件
您需要配置开发者凭据以允许 Home Assistant 访问您的 Google 账户。 这些凭据与 Nest、Google Sheets 和 YouTube 的凭据相同。 这些与之前为 Google Calendar 推荐的 Device Auth 凭据不同。
Scenario 1: You already have credentials
In this case, all you need to do is enable the API:
- Go to the Google Developers Console Gmail API.
- Confirm the project and select Enable for the API.
- Continue with the steps described in the Configuration section.
Scenario 2: You do not have credentials set up yet
In this case, you need to generate a client secret first:
To generate client ID and client secret
This section explains how to generate a client ID and client secret in the Google Developers Console.
- First, go to the Google Developers Console to enable Gmail API.
- Select Create project, enter a project name, and select Create.
- Enable Gmail API.
- Navigate to APIs & Services > Credentials.
- In the left sidebar, select OAuth consent screen.
- Complete the app information and create the consent screen.
- Under Publishing status > Testing, select Publish app.
- In the left sidebar, select Clients and create a Web application client.
- Add
https://my.home-assistant.io/redirect/oauthto Authorized redirect URIs and select Create. - Copy the Client ID and Client Secret before closing the dialog.
此集成可通过 UI 配置。前往 设置 > 设备与服务 添加。
The integration setup then gives you instructions to enter the Application Credentials and authorize Home Assistant to connect to Google Mail.
OAuth and device authorization steps
- Continue through the steps of selecting the account you want to authorize.
- You may get a message telling you that the app has not been verified and that you need to acknowledge it to proceed.
- Review what Home Assistant is requesting access to, then select Continue.
- When the page displays Link account to Home Assistant?, confirm that Your instance URL is correct, then select Link Account.
- You can close the window and return to Home Assistant, where you should see a Success! message.
故障排除
如果您的凭据出现错误,可以在应用程序凭据用户界面中删除它们。
动作:设置假期
google_mail.set_vacation 动作允许您设置假期选项。
创建事件动作详情
添加的 notify 服务将以您在同意屏幕上选择的电子邮件地址命名。例如,名为 "example@gmail.com" 的电子邮件地址将显示为 notify.example_gmail_com。
Google Mail 通知动作数据
以下属性可以放置在动作的 data 键中以实现扩展功能:
示例
这是发送电子邮件的完整服务调用:
视频教程
此视频教程说明了如何在 Home Assistant 中设置 Gmail,以及如何创建仪表板和自动化来发送电子邮件和切换您的外出通知。

