2026年7月1日

Google Mail

The Google Mail integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] allows you to connect your Google Mail to Home Assistant. The integration adds an action to allow you to set an email auto-response for when you go on vacation. A notify action is also added, allowing you to draft or send emails in plain text.

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 and Google Sheets and YouTube. These are not the same as Device Auth credentials previously recommended for Google Calendar.

Scenario 1: You already have credentials

In this case, all you need to do is enable the API:

  1. Go the Google Developers Console Gmail API .
  2. Confirm the project and Enable the API.
  3. 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 on Google Developers Console.

  1. First, go to the Google Developers Console to enable Gmail API .
  2. Select Create project, enter a project name and select Create.
  3. Enable the Gmail API.
  4. Navigate to APIs & Services (left sidebar) > Credentials.
  5. In the left sidebar, select OAuth consent screen.
  6. It will take you to the Overview page and ask for Project Configuration:
    • Complete the App Information:
      • Set the App name (the name of the application asking for consent) to anything you want, for example, Home Assistant.
      • For a Support email, choose your email address from the dropdown menu.
      • Select Next.
    • For Audience, select External then select Next.
    • Under Contact Information, enter your email address (the same as above is fine). Select Next.
    • Read the policy and check the box if you agree. Select Continue.
    • Select Create.
  7. In the left sidebar, select Audience:
    • Under Publishing status > Testing, select Publish app.

      Otherwise, your credentials will expire every 7 days.

  8. In the left sidebar, select Clients:
    • Select + Create Client.
    • For Application type, choose Web Application and give this client ID a name (like "Home Assistant Client").
    • Add https://my.home-assistant.io/redirect/oauth to Authorized redirect URIs then select Create.

      Note: This is not a placeholder. It is the URI that must be used.

  9. From the resulting dialog take a note of Client ID and Client Secret you can not retrieve it again after closing the dialog.
    • Once you have noted these strings, select Close.
    • Congratulations! You are now the keeper of a client secret. Guard it in your treasure box. In most cases, your new credentials will be active within a few minutes. However, Google states that activation may take up to five hours in some circumstances.

Configuration

To add the Google Mail service to your Home Assistant instance, use this My button:

Manual configuration steps

If the above My button doesn’t work, you can also perform the following steps manually:

  • Browse to your Home Assistant instance.

  • Go to Settings > Devices & services .

  • In the bottom right corner, select the Add Integration button.

  • From the list, select Google Mail.

  • Follow the instructions on screen to complete the setup.

The integration setup will next give you instructions to enter the Application Credentials (OAuth Client ID and Client Secret) and authorize Home Assistant to connect to Google Mail.

OAuth and device authorization steps
  1. Continue through the steps of selecting the account you want to authorize.

  2. NOTE: You may get a message telling you that the app has not been verified and you will need to acknowledge that in order to proceed.

  3. You can now see the details of what you are authorizing Home Assistant to access with two options at the bottom. Select Continue.

  4. The page will now display Link account to Home Assistant?, note Your instance URL. If this is not correct, refer to My Home Assistant. If everything looks good, select Link Account.

  5. You may close the window, and return back to Home Assistant where you should see a Success! message from Home Assistant.

Sending emails

The notify action added by this integration is named after the email address you chose on the consent screen. For example, an email address named "[email protected]" will display as notify.example_gmail_com.

The following attributes can be placed inside the data key of the action for extended functionality:

  • cc: List of recipients to be carbon-copied.
  • bcc: List of recipients to be blind-carbon-copied.
  • from: Defaults to the current authenticated user. Typically only applies to Google Workspace accounts where the user has delegate access to a shared mailbox.
  • send: Defaults to true. Set this to false to create a draft instead. Recipients are not required in this case.
  • alias_from: Name that is shown to the recipients instead of your email address. To use this option, you must also set from.

This is the full action to send an email:

action: notify.example_gmail_com
data:
 message: "test"
 title: "testemail"
 target:
 - "[email protected]"
 data:
 cc:
 - "[email protected]"
 bcc:
 - "[email protected]"
 from: "[email protected]"
 alias_from: "Examplealias"

List of actions

The Google Mail integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides the following actions. Each link below opens a dedicated page with examples, parameters, and a step-by-step UI walkthrough.

  • Set vacation (google_mail.set_vacation) Sets the vacation auto-responder for a Google Mail account.

For an overview of every action across all integrations, see the actions reference.

Video tutorial

This video tutorial explains how to set up Gmail in Home Assistant and how you can create a dashboard and automations to send email and toggle your out-of-office notice.

Troubleshooting

If you have an error with your credentials, you can delete them in the Application Credentials user interface.

Help us improve our documentation

Suggest an edit to this page, or provide/view feedback for this page.

AltStyle によって変換されたページ (->オリジナル) /