Integrate Google Calendar with Home Assistant
In this tutorial, I am going to share how you can easily integrate the Google Calendar with Home Assistant.
Generate a Client ID and Client Secret on Google Developers Console
Create an account in Google and go to the Google Developer Console.
- Select Create a project and click Continue.
- Click Go to credentials.
- Click Cancel.
- Navigate to Credential menu on the APIs and services on the left hand side bar.
- Click on the CONFIGURE CONSENT SCREEN.
- On the OAuth consent screen, select External and click Create.
- On the OAuth consent tab: App information section, set the App name (for example Home-Assistant-GCal) and set the support email by click drop down and select your email address.
- On the OAuth consent tab: Developer contact information section, set your email address. Click Save and Continue.
- On the Scopes tab, you don’t need to fill in anything, just click Save and Continue.
- On Test users tab, click Add Users.
- You will need to add the Gmail address you will be using with this integration as a test user before you will be allowed to use the API. Add the user’s email address and click Add.
- Once you have added, click Save and Continue.
- It then comes to the Summary tab. You don’t need to do anything on this tab.
- Go back to the APIs and services menu on the left hand side, select Credentials and select Create Credentials.
- Select OAuth client ID.
- Select TVs and Limited Input devices.
- Set a name, for example Home Assistant Gcal Credentials, then click Create.
- Take note the Client ID and Client Secret. We will be using this information and update the configuration.yaml later in Home Assistant.
- The last here, is to ensure the Google Calendar API is enabled. Select Library and search for Google Calendar API and check if the API is enable or not. If not, enable it. We are done with generating a Client ID and Client Secret on Google Developers Console for Google Calendar.
Home Assistant Configuration
To integrate Google Calendar in Home Assistant, add the following section to your
configuration.yaml file. Enter the client_id and client_secret that you have generated from the earlier step.
# Example configuration.yaml entry
And then restart your Home Assistant. Once you have restarted you will see a new notification that gives you a link and an authentication code. Click that link and enter the authentication code. This will grant your Home Assistant service
read-write access (based on configuration) to all the Google Calendars that the account you authenticate with can read.
If you get an error saying the authentication code is expired, set the timezone to Etc/GMT as a workaround and restart the Home Assistant. Once you have linked and granted, change back the timezone setting to the original.
Once the setup is done and you have restarted the Home Assistant, you will see the Calendar menu on the left hand side and the google_calendars.yaml is created under the config folder.
With every restart all calendars of the configured Google account will get pulled and added to the
google_calendars.yaml and preconfigured as a single entity. By setting the ‘track’ variable to
true the calendar will get monitored for new events which can be used for automations and its content is shown on the ‘Calendar’ dashboard (mind ‘max_results’ is set to 5 by default).
That’s all for now. We’ll learn how to create an automation using Google Calendar in the next tutorial. Stay tuned.
Home Assistant — Home Calendara Event https://www.home-assistant.io/integrations/calendar.google/