Google Calendar

The Google Calendar integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] allows you to connect your Google Calendar to Home Assistant. The integration adds calendarA calendar entity represents a schedule of events coming from a local or external calendar source. It can be used to trigger automations based on the start or end of an event, react to offsets (like 15 minutes before), or retrieve event details through services. [Learn more] entities that are shown on the Calendar dashboard, and can be used for automations based on any event, or limited to specific matching criteria.

Prerequisites

You need to configure developer credentials to allow Home Assistant to access your Google Account. The current recommended approach is to create Web Auth credentials for Google Calendar since the same credentials work for all Google integrations. Previously, this integration only supported Device Auth and those credentials are no longer recommended. You can continue to use Device Auth credentials but they will only work with Google Calendar.

Scenario 1: You already have credentials

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

  1. Go to the Google Cloud console Google Calendar API .
  2. Confirm that the correct project is selected, then select Enable.
  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 in the Google Cloud console.

  1. Go to the Google Cloud console.
  2. Select Create or select a project, then New project, enter a project name, and select Create.
  3. When the project opens, make sure it is selected in the console toolbar at the top. If it isn’t, select it.
  4. Go to Google Calendar API , then select Enable.
  5. Go to the Branding page in the Google Auth Platform Console.
  6. If Google Auth Platform is not configured, select Get started:
    • Under App Information, enter an app name (for example, Home Assistant) and select your email address for User support email. Then select Next.
    • Under Audience, select External, then select Next.
    • Under Contact Information, enter your email address, then select Next.
    • Review the Google API Services User Data Policy. If you agree, select the check box, then select Continue and Create.
  7. In the left sidebar, select Branding:
    • Under App domain, enter https://home-assistant.io for Application home page, Application privacy policy link, and Application terms of service link.
    • Under Authorized domains, add home-assistant.io.
  8. In the left sidebar, select Audience:
    • Under Publishing status, select Publish app.

      Otherwise, your credentials will expire every 7 days.

    • If you leave the app in Testing, under Test users, select Add users, add your Google Account email address, then select Save.
  9. In the left sidebar, select Clients:
    • Select Create client.
    • For Application type, choose Web application and give the client a name (for example, Home Assistant Client).
    • Under Authorized redirect URIs, add https://my.home-assistant.io/redirect/oauth, then select Create.

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

  10. From the resulting dialog, take a note of the Client ID and Client Secret. You cannot retrieve it again after closing the dialog.
  • Once you have noted these strings, select Ok to 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 Calendar 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 Calendar.

  • 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 Calendar.

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.

Troubleshooting

If the setup process fails and you see an error message such as Authentication code expired, please try again you may want to try the flow again. You may also check the logs for additional error messages that may indicate a misconfiguration such as an invalid client id or secret.

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

Video tutorial

This video tutorial explains how to set up Google Calendar in Home Assistant and how you can trigger an automation based on a calendar event.

Calendar entities

Each Google Calendar from My Calendars (more info) is represented as a calendar entity in Home Assistant.

For example, your calendar named Personal is created as entity calendar.personal. You may rename an entity, or disable any entities which you don’t need.

Calendar event automations

Individual Calendar Events are what is powering automations such as:

  • Turn on a light at the start of the event named Front Yard Light
  • Send a notification 5 minutes before the start of any event
  • Stop the media player 30 minutes after the end of the event named Exercise.

See calendar automations for an overview, and read more about calendar trigger variables for the available information you can use in a condition or action such as the event summary, description, location and more.

Calendar entity attributes

The calendar entity has additional attributes related to a single next upcoming event.

Tip

Using the entity state and attributes is more error prone and less flexible than using Calendar Automations. The calendar entity itself may only track a single upcoming active event and can’t handle multiple events with the same start time, or overlapping events.

Attributes
  • all_day: true/false if this is an all day event. Will be false if there is no event found.
  • message: The event summary.
  • description: The event description.
  • location: The event location.
  • start_time: Start time of event.
  • end_time: End time of event.

List of actions

The Google Calendar 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.

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

More configuration

More Configuration

Warning

It is not recommended to new users to use these settings as they are not compatible with other Home Assistant features, but this documentation is available for existing users.

The integration supports additional configuration from a file google_calendars.yaml which is available for existing users before version 2022.06. This file is no longer automatically populated.

Configuration Variables

cal_id string Required

The Google generated unique id for this calendar.

Default:

DO NOT CHANGE THE DEFAULT VALUE

entities list Required

Yes, you can have multiple sensors for a calendar!

device_id string Required

The name that all your automations/scripts will use to reference this device.

name string Required

What is the name of your sensor that you’ll see in the frontend.

search string (Optional)

If set will only trigger for matched events.

offset string (Optional, default: !!)

A set of characters that precede a number in the event title for designating a pre-trigger state change on the sensor. This should be in the format of HH:MM or MM.

ignore_availability boolean (Optional, default: true)

Should we respect free/busy flags?