Home » Blog » How To Use Calendar Events in Home Assistant – Tutorial

How To Use Calendar Events in Home Assistant – Tutorial

Hi! You may know that you can link your Google calendar or local calendar to Home Assistant. I explain in this video how to set up your Google Calendar in Home Assistant and how to use the calendar events to trigger automations. In addition, I created a new blueprint for your Ulanzi Desktop Clock or other clocks that use Awtrix Light to be notified of new events on that clock.


⭐⭐⭐ NOTE: ⭐⭐⭐

This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. To keep doing this, I would like to ask you to check out the video, leave a comment under the video, give the video a thumbs up, and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.

Thank you for your support!

Ed

Click here to watch the video

I just recently set up my Google calendar in Home Assistant. But I never thought it was needed, because the native Google Calendar app already sends messages to my phone. I didn’t think it would add much value to let Home Assistant send messages to my phone as soon as a calendar event starts as well. Then, someone made me aware that I can show calendar events on My Ulanzi Desktop Clock or other clocks that use Awtrix Light.

If you want to know more about this clock and how to use it in Home Assistant, then check out this video. Next to showing a list of events, you can show an alert on your clock or dashboard when a calendar event occurs. I will show you in this Home Assistant tutorial how I show an alert on my phone and Ulanzi Desktop Clock 15 minutes before a calendar event starts.

Setting up Google Calendar in Home Assistant

There are multiple ways to set up a calendar in Home Assistant. You can use a local calendar or you can use the Google Calendar Integration. I use Google Calendar myself for all my appointments. So, let’s set up the Google Calendar Integration in Home Assistant first!

Generate Client ID and Client Secret

We start with generating a client ID and client secret. For that, go to the Google Developers Console and make sure that you are logged in with the Google Account that holds your Google calendar. If you do not have a project defined yet, you have to create one first. In my case, I already created a project before, but I will add a new one anyway to show you the process.

  • Click on the project dropdown and either select an existing project or click on New Project.
  • I will click on New Project for now.
  • Enter a Project name.
  • You can select an organization or folder, but I will leave it to default.
  • Click “Create”.
  • The project will now be created.
  • After it’s been created, select your new project in the dropdown.
  • You might get the error message that I got here. This means that you have to enable the API for the project. You can do that at a later stage, but I choose to do it now.
  • Click on the menu icon and select the menu option APIs & Services.
  • Select Library.
  • Search for “calendar”.
  • Select Google Calendar API.
  • Click “Enable”.
  • Now click on the menu item Credentials.
  • You’ll see that there are no credentials yet for this new project. First, we need to create an app.

Create the App

  • Click on OAuth Consent screen.
  • Select External at User Type.
  • Click Create.
  • Enter an App name like Home Assistant Calendar,
  • And select a user support email.
  • Scroll down and enter an email address for the developer contact information. This can be the same email address that you used for the user support email.
  • Click Save And Continue.
  • You will see the Scopes page now. Click Save and Continue again.
  • After this, you will see the Test Users Page. You do not have to enter a test user here.
  • Now go to the OAuth consent screen and click Publish App.
  • Click Confirm to push your app to production.
  • Now click on Credentials again.
  • Click Create Credentials.
  • Select OAuth Client ID.
  • Select TVs and Limited Input devices in the Application type dropdown list.
  • Give your client a name, for instance, Home Assistant Credentials.
  • Click Create.
  • Your OAuth Client is now created. Copy the Client ID and Client Secret and paste them into a text file or something. You will need the Client ID and Client Secret in a minute when you set up the calendar integration in Home Assistant.
  • Click OK.
  • Now, let’s double-check if our API is enabled. It should be because we enabled it at the beginning of the process.
  • Click on Library.
  • Search for Google Calendar API.
  • Click on Google Calendar API.
  • If all went well, you should see the API enabled. If not, enable it to complete the process.

Okay, we’ve set up the Client ID and Client Secret for our Google Calendar now and hopefully you stored the Client ID and Client Secret in a text file somewhere, because we will need them for the next step.

I need your help!

You will be doing me a huge favor if you subscribe to my channel if you haven’t already. And, you help me a lot if you also give this video a thumbs up and leave a comment. This way, YouTube will present this video to new people and that will make the channel grow! In the description of the video, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.

Thank you!

Setting up the Google Calendar Integration in Home Assistant.

So, let’s go to Home Assistant!

  • Click on Settings and go to Devices And Services.
  • Click Add Integration.
  • Search for Google Calendar.
  • Click Google and Click Google Calendar.
  • Enter a name for your Calendar and enter the OAuth Client ID and OAuth Client Secret that you created in the previous steps.
  • Click Add.
  • Now copy and paste the code that you see in the dialog box.
  • Click on the link to go to the Google Account Link page.
  • Enter the code on that page,
  • and click Continue.
  • Now select the Google account that holds your calendar.
  • It might be that you will get a message that the app is not verified. Don’t worry, just click on the Advanced link and click on the “Go to Home Assistant Calendar (unsafe) link.
  • Click “Allow”.
  • Your device is now connected.
  • Open your Home Assistant tab and you will see that the Google Calendar Integration is successfully authenticated.
  • Click Finish.
  • If everything went well, you will see a new Calendar entry in your left menu.
  • Click on the Calendar entry and your Google calendar will be visible.
  • Depending on the settings of your Google calendar, you might see various calendars here. Just disable the ones that you do not want to see.

This is great! You now connected your Google Calendar to Home Assistant. So now we can create automations that trigger based on events in your Google Calendar.

How to create Automations based on your Google Calendar Events.

I will show you a simple example of how you can send a message to your phone when an event starts. Next to that, I created a Blueprint for the Ulanzi Desktop Clock or any other clock that runs Awtrix light. This Blueprint shows the upcoming events for the next couple of hours that you want to see. Next to that, it warns you about an upcoming event 15 minutes before it starts.

This Blueprint is part of the Blueprint pack that I developed for Awtrix Light and works with any clock that runs Awtricx Light. If you want to know more about these Blueprints, then please watch this video where I explain how they work. The link to the Blueprints can be found in the description below the video. I am constantly adding new features to the Blueprints and you can always download the latest version for free if you’ve purchased them before.

But, let me show the automation that I’ve created to send a message to your phone when an event starts.

Set up the automation

  • For this, go to Settings -> Automations and Scenes.
  • Click Create Automation.
  • Click Create New Automation.
  • At Triggers, click Add Trigger.
  • Select Calendar.
  • Select your Calendar.
  • Enter an optional Offset. I enter 15 minutes before so that the automation gets triggered 15 minutes before the event starts.
  • Now go to the Actions part and click “Add Action”.
  • Select Call Service.
  • Select Notify for the device you want to notify.
  • Enter a tile like Calendar Event.
  • We are going to enter some template code in the message field to show the event data in the message that will be sent to your phone.
  • When you start entering template code, the interface will automatically go into YAML mode.
  • Enter the following code:
Event {{ trigger.calendar_event.summary }} starts at {{ trigger.calendar_event.start }}
  • The trigger.calendar_event.summary will show the topic of the calendar item.
  • The trigger.calendar_event.start will show the time and date of the event.
  • Click SAVE.
  • Give your automation a meaningful name.

Your automation is now created and will send a message to your phone 15 minutes before the vent starts. You can of course add other actions as well.

Keep in Mind

There’s one thing you need to keep in mind and that is that the calendar syncs every 15 minutes, so if you plan a test event within 15 minutes from now, it won’t be picked up by Home Assistant. So, make sure you plan your events later than in the next 15 minutes to test. You can also force the calendar to sync by going to the developer tools and the Services tab and selecting the service Home Assistant Core Integration: Reload config entry. For the target select your calendar.

When you use the Blueprints for the clock, it will show you all the upcoming events and will show a notification 15 minutes before an event starts.

So, this is how you can set up Google Calendar in Home Assistant and trigger automations based on events. Now you know how you can set it up yourself. I put a lot of time into these videos and if they save you time and frustration please consider sponsoring me just like these wonderful people do. I cannot keep doing this without your help. You’ll find the links to Patreon, Ko-Fi, and how to become a member of this channel in the description of this video. And please do not forget to give this video a thumbs up and subscribe to my channel to make the channel grow.

I’ll see you soon in my next video.

Bye Bye!


,

Back to all articles