We all know that Home Assistant is a versatile smart home platform that allows you to automate just about any connected light, switch, and thermostat. But it isn't just physical objects Home Assistant tracks and controls, the virtual world is just as much a part of the platform. Thanks to the work done by developer vasqued2, which resulted in the Team Tracker custom integration, this includes sports teams and athletes. In this article, I will show you how to track your favourite team, from just about any sport, using the Team Tracker integration in Home Assistant. And since a well-structured and informative Home Assistant Dashboard is desired by everyone, I will demonstrate how to showcase your team's upcoming game in a visually appealing card.
Contents
Prerequisites: Setting up Home Assistant and HACS
To begin monitoring your favourite sports team and integrating it with your smart home, you need to first set up Home Assistant. This requires installing the platform on a host device like a Raspberry Pi and configuring it with the required components. The installation process for Home Assistant is well documented and simple to follow, as outlined in the Home Assistant Beginner's Guide, so I won't delve into it further here.
To ensure optimal functionality, it's recommended to make use of the Home Assistant Community Store (HACS) to install the Team Tracker custom integration. While manual installation of custom integrations is an option, it is not the preferred method due to the potential for errors and increased time commitment. HACS provides a hassle-free way to update components, keeping all files organized and configurations accurately set.
How Home Assistant fetches real-time sports scores
The Home Assistant custom component by vasqued2 makes use of the expansive ESPN APIs to fetch live scores. Using the custom integration, the following sports can be set up and tracked without complications in Home Assistant:
- Australian Football: AFL (Australian Football League)
- Baseball: MLB (Major League Baseball)
- Basketball: NBA (National Basketball Association), WNBA (Women's National Basketball Association), NCAAM , and NCAAW
- American football: NFL (National Football League) and NCAAF (NCAA Division I Football Bowl Subdivision)
- Golf: PGA
- Hockey: NHL (National Hockey League)
- MMA: UFC
- Football: Champions League, English Premiere League, Bundesliga, LaLiga, Ligue 1, Serie A, MLS (Major League Soccer), NWSL (National Women's Soccer League), and the World Cup
- Racing: Formula 1 and Indy Racing League
- Tennis: ATP Tour and WTA
- Volleyball: NCAAVB and NCAAVBW
- Cricket: Follow this guide to set up a sensor in Home Assistant
Configuring your favourite sports team
With the ESPN API integrated into Home Assistant via the Team Tracker custom component, you are now ready to set up tracking for your favourite sports team. This involves specifying the team you want to follow. Add a new integration to Home Assistant using the Dashboard, and search for Team Tracker. Then, select a league from the list provided in the description and select your team. You can find the team's abbreviation in the scorecards on ESPN's website, for example, you would enter “TOT” to receive updates on Tottenham Hotspur.
Examining the sensor created by the integration, you will notice that numerous attributes are added. These attributes include the next opponent of your team, the stadium where the game will be played, the form of each team and their logos, and the date and time of the game. These attributes are collected for a purpose, which will be covered in the next step.
Display your team's matches in the Home Assistant Dashboard
The Team Tracker Card was designed to complement the Team Tracker custom integration. With this card, you can showcase your team's upcoming match, form, and in-game events. Currently, only the next match can be displayed and not a list of future games. While some customization options are available, they won't significantly alter the appearance of the card. As with the custom component, it is recommended that you install the Team Tracker Card using HACS.
Adding custom sports, leagues, and cups to Home Assistant
While setting up the Team Tracker component, I encountered an issue that you may also face: certain leagues and cups were not readily available. In my case, it was the League Cup and FA Cup. To find additional leagues, the recommended approach is to visit ESPN's API explorer, open the Score & Schedules API, and search for the league or cup name by entering the sport name.
You can then add the following sensor to your configuration.yaml
file. In my case, the league_id
remains set to XXX
, while the team_id
is the same as previously looked up. Input the sport name and league_path
obtained from the API explorer. After restarting Home Assistant, you will have a sensor tracking Manchester United's progress in the FA Cup.
sensor:
- platform: teamtracker
league_id: XXX
team_id: MAN
sport_path: soccer
league_path: eng.fa
name: tt_elc
I was unable to locate the League Cup in the API explorer and had to resort to an alternate method to determine the league_path. I opened the competition's page on ESPN and was able to obtain the accurate descriptor from the page's URL.
https://www.espn.com/soccer/schedule/_/league/**eng.league_cup**
My final configuration for the League Cup thus looked like this:
sensor:
- platform: teamtracker
league_id: XXX
team_id: MAN
sport_path: soccer
league_path: eng.league_cup
name: tt_elc
With cups, chances are that your team won't make it into the final round. This could lead to your Home Assistant Dashboard not being as pretty as you would expect because it is cluttered with Team Tracker Cards that can't find a valid game. To avoid this scenario, conditional cards can be used, and the Team Tracker wiki provides an example on how to set such cards up.
Conclusion
Tracking your favourite sports team in Home Assistant is a fun and easy process that provides you with a wealth of information about your team and its games. With the Team Tracker custom integration and a few simple configurations, you can create a customized experience that meets your needs and keeps you up to date on all the latest scores and player stats. Whether you're a die-hard sports fan or just someone who wants to keep track of their favourite team, Home Assistant has you covered.