How To Setup Google Calendar Event Notifications in Home Assistant

by Danny
0 comment

READING TIME: 4 MINUTES

In this guide, I’m going to show you how to configure Google Calendar Event notifications before an event starts in Home Assistant.

This setup can get pretty complex and largely dependent on your own personal use case, so I’m just going to go over the basic usage in this guide, but there’s more info the Google Calendar integration page you can reference if needed.

For this tutorial, I’m am going to be creating an automation that alerts me 60 minutes before a football games starts.

Let’s get started!


Prerequisites:

This guide assumes you already have Google Calendar integrated in Home Assistant.

If you would like to import your favorite sports team schedules, you can follow these guides:


Create Automation When An Event Starts

To create an automation when a generic event starts, you can create this basic automation. This won’t tell you exactly what the event is (at least, I haven’t figured out a way to format that into the message yet), but it could be useful for generic reminders (such as walk the dog, medication reminders, garbage reminders, etc).

Configuration > Automations.

alias: Generic Event Notification
description: ''
trigger:
  - platform: state
    entity_id: calendar.your_calendar_entity_id
    to: 'on'
condition: []
action:
  - service: notify.mobile_app_pixel_5_danny
    data:
      message: Check your calendar.
      title: Event started!
mode: single

Basically, a calendar event has a state of “off” in Home Assistant until the time it starts. Then it toggles to “on”. You can view this behavior under Developer Tools > States > filter by your calendar entity:


Create “Time Until” Sensor

In my previous Lovelace Sports Card guides, I’ve already added the Michigan State Football schedule, which has an entity ID of: calendar.michigan_state_spartans_football which will be used for this time_until sensor.

To be notified before the game starts, we need to create a new sensor called time_until_msu_football, that way we can trigger an automation before the event starts.

File Editor > Configuration.yaml. Under your sensors: section, add this code replacing the calendar with your own and give it a helpful sensor name.

- platform: template
    sensors:
      time_until_msu_football:
        friendly_name: Time Until MSU Football Game
        unit_of_measurement: minutes
        value_template: >-
          {% if states.calendar.michigan_state_spartans_football.attributes.start_time %}
            {{((as_timestamp(states.calendar.michigan_state_spartans_football.attributes.start_time) - as_timestamp(now())) / 60) | int }}
          {%- else -%}
            0
          {%- endif %}

Then, reboot Home Assistant. Add the time_until_msu_football sensor to an Entities card to verify it is counting down correctly. It should update every 1 minute.


Create Google Calendar Event Automation

This automation will send you a notification 1 hour (60 minutes) before a game starts (using the new sensor we created above).

Go to Configuration > Automations. Create a new automation.

You can also change anything under the Action section, such as turning on lights, running a scene, changing your RGB light strip to your teams colors, and much more.

alias: Football Game 1 Hour Reminder
description: ''
trigger:
  - platform: state
    entity_id: sensor.time_until_msu_football
    to: '60'
condition: []
action:
  - service: notify.mobile_app_pixel_5_danny
    data:
      message: MSU Football will start in 1 hour.
      title: Game Time!
mode: single

Wrapping Up

All in all, Google calendar events can be automated as much or as little as you want depending on your needs and use cases. I’ve found it’s a lot easier to just use Google Calendar reminders for regular events, but it’s still cool that you can use event notifications to turn lights on, turn your TV on and start the pre-game, etc.

Let me know what cool notifications or automations you’ve created!


My Favorite Home Assistant Devices

Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.

The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.

0 comment

You may also like

Leave a Comment