Automating GameDay

This post may contain affiliate links. Please read my disclaimer for more info.

Football season is upon us and I wanted to automate the lights in my house for my favorite team. I was looking for a way to trigger some automations a few hours before the game to set the lighting around my house and get in the gameday spirit!

Read on to learn how I used Home Assistant, Google Calendar, and a template sensor to track when my team plays and create automations leading up to the game.

Google Calendar for Team Schedule

Subscribing to Your Team

To automatically get your team’s schedule, you can leverage Google Calendar. Using a calendar subscription you’ll automatically get the correct times for when your team kicks off, even if the game changes times (which happens often in college football). Google Calendar has team calendars you can subscribe to. We can then use the Home Assistant integration to create automations. Adding your sports team to Google Calendar is very straightforward.

Go to calendar.google.com and click on the “Gear” icon in the top right.

Click Gear on Google Calendar

On the left-hand side, under “Add calendar”, choose “Browse Calendars of interest”.

Browse Calendars of Interest

From there, you can browse for your favorite team and add them to your calendar.

Choose Team

After subscribing, you should see the calendar for your team in your Google Calendar.

Adding to Home Assistant

Now that your team’s calendar is displayed in your Google Calendar, we just need to hook up Home Assistant to use Google Calendar as well.

The Home Assistant documentation has some great instructions on how to enable Google Calendar using the official Google API. Rather than repeat them here, I recommend you read through their instructions.

Once complete and Home Assistant has been restarted, you should get a notification indicating that Google Calendar has been set up successfully.

Google Calendar Setup Complete 

You’ll now have a google_calendars.yaml file generated in your Home Assistant configuration directory. You can edit this file to change how Home Assistant interacts with your calendars. You can set track: false for any calendars you don’t want Home Assistant to create sensors for.

Custom Offset Sensors

If you want to create automations that start at a preset time before the event starts, it can be helpful to create custom sensors that show the time before the next event occurs. I’m using a template sensor to calculate the number of minutes kickoff.

You can see in the above sensor configuration, the value of the sensor is calculated as the number of minutes between the start time and the current time. I had to explicitly add the sensor.time entity to the entity_id to tell the template sensor it needs to be updated every minute. The value of the sensor basically goes down by 1 every minute until the game starts.

This allows to easily create automations leading up to kickoff by triggering on the value.

Creating Automations

With this custom template sensor set up, creating an automation before kickoff is really easy. For example, I wanted to set the lights in my house to a specific color starting an hour before kickoff.

The above automation basically triggers whenever the “time_until_next_game” sensor reaches “60”. It then triggers a scene to set lights correctly around my house to set the atmosphere of the game. For example, my under cabinet kitchen lighting changes to burnt orange to support my Texas Longhorns.

It also announces over my Google Home that the game will kickoff in an hour using the Google TTS integration.

I have another automation that triggers after the game has ended. Unfortunately, the Google Calendar end times don’t really reflect the actual end times of the game. They typically estimate about 3 hours for football. To give some buffer, my automation triggers an hour and a half after the game has ended in Google Calendar.

So while this doesn’t trigger exactly when the game ends in real life, it does reset the lights back in a reasonable amount of time after the game ends.

Summary

What are you doing to automate your game day? I think there is a lot of potential here to create an awesome atmosphere when supporting your favorite team if you’re a sports nut like me. If you are an NHL or MLB fan, you should check out the goalfeed Home Assistant integration to create some automations whenever your team scores.

Let me know in the comments what your game day looks like and how you could use Home Assistant!

Please consider supporting the blog by joining my mailing list, following the blog on social media or directly through Buy Me a Coffee. Thanks for reading!