Real-Time Sports Scores w/ TeamTracker and TeamTracker-Card (Beta)

A pre-release version of the integration and card with localization capabilities is available from HACS by manually downloading the ‘main’ and/or ‘master’ version. They will be the last choice in the download list after the official releases. Note that if you download these pre-release versions, you can re-download an official release at any time. You will not get version upgrade notices as long as you are on the pre-release version and you will have to revert back to an official release at some point to get them.

Localization is driven by the language selected for the HA front end. Localization occurs at three different levels.

  • API Level - The selected language for the HA front end is sent to the ESPN API and it translates its response into to the selected language. Information returned by the API includes team names, clock, quarter, period, half, and last play. Whenever information if returned from the API, I display it as returned. This will occur in the next API call after the language is changed in the front end. Depending on if the game is in progress or not, this will take 10 seconds or 10 minutes.
  • Dates and Times - Dates and times will be translated and formatted based on the language selected for the HA front end. This will occur immediately when a language is changed on the front end.
  • Teamtracker-specific terms - The teamtracker-card uses a number of specific terms such as ‘Kickoff’, ‘Win Probability’, and ‘API Error’. These terms are translated with a simple translation engine. A language-specific translation file is required for each desired language. I’ve included some sample translation files as a base that need to be updated. New files for other languages can be added. Translation will occur immediately once a language is changed and will default to English if no language-specific file exists.

The language files are stored in the teamtracker-card/localize/languages directory. There is a README with more information on how to add a new language in the localize directory. If you want to add a new language file, submit a pull request or get me the language file in some other manner and I will add it.

I am targeting the official release of this functionality early next week as long as there are no issues. I will include any language files I get by then in that first release.

good, excellent work. there is a problem with soccer, the integration returns these “NOT_FOUND”, the game is live and returns this

The abbreviation for Manchester City is MNC, not MCI. Change it and it works.

mnc

You can tell by the abbreviation ESPN uses on their pages.

I tried with MNC that appears on the page and with MCI that appears in the ESPN application, but it returns something the same.

i am not using yaml.

Are you using the pre-release version that supports other languages or v0.4.0?

If you are using the pre-release version, let me know what language you are using.

If you are using v0.4.0, we are going to have to look at the debug logs.

  1. Add the following to the configuration.yaml file.
logger:
  default: info
  logs:
    custom_components.teamtracker: debug
  1. Restart
  2. Search for MCI and/or MNC in the full logs.

Here’s what I get using MNC, which indicates it is working correctly.

2022-10-08 11:33:52.177 DEBUG (MainThread) [custom_components.teamtracker] Getting state for MNC from http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard?lang=en
2022-10-08 11:33:52.190 DEBUG (MainThread) [custom_components.teamtracker] Found event for MNC; parsing data.

Here’s what I get using MCI, which indicates it is not working correctly.

2022-10-08 11:35:43.219 DEBUG (MainThread) [custom_components.teamtracker] Getting state for MCI from http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard?lang=en
2022-10-08 11:35:43.241 DEBUG (MainThread) [custom_components.teamtracker] Did not find a game with for the configured team(MCI). Checking if it's a bye week.
2022-10-08 11:35:43.242 DEBUG (MainThread) [custom_components.teamtracker] Competitor information (MCI) not returned by API: http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard?lang=en

I will need to know the value of the API to troubleshoot further if you are using v0.4.0

If you were using the pre-release version, I think I see the problem.

It looks like ESPN actually uses two different abbreviations when the language is set to ‘es’. And probably any other language other than ‘en’. My logic assumes the one abbreviation is for the team everywhere.

ESPN uses ‘SOU @ MNC’ when you search for the match but ‘MCI’ for the abbreviation for the in-game team info when the language is Spanish (it uses MNC in both places when it’s English). It was your comment about seeing the different abbreviations on the web page and the app that helped me figure out what was going on. Thanks.

Glad you caught this before it got officially released. I’m going to have to make some updates to the pre-release version to handle this situation.

Now that the game is over, can you confirm that you are getting the final result w/ the scores?

Thanks for your help.

I use version 0.4.0

´2022-10-08 11:24:16.344 DEBUG (MainThread) [custom_components.teamtracker] Getting state for RMA from http://site.api.espn.com/apis/site/v2/sports/soccer/esp.1/scoreboard
2022-10-08 11:24:16.352 DEBUG (MainThread) [custom_components.teamtracker] Getting state for BAR from http://site.api.espn.com/apis/site/v2/sports/soccer/esp.1/scoreboard
2022-10-08 11:24:16.358 DEBUG (MainThread) [custom_components.teamtracker] Getting state for LIV from http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard
2022-10-08 11:24:16.366 DEBUG (MainThread) [custom_components.teamtracker] Getting state for MNC from http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard
2022-10-08 11:24:16.445 DEBUG (MainThread) [custom_components.teamtracker] Found event for RMA; parsing data.
2022-10-08 11:24:16.462 DEBUG (MainThread) [custom_components.teamtracker] Finished fetching Real Madrid data in 15.603 seconds (success: True)
2022-10-08 11:24:16.472 DEBUG (MainThread) [custom_components.teamtracker] Did not find a game with for the configured team(BAR). Checking if it’s a bye week.
2022-10-08 11:24:16.472 DEBUG (MainThread) [custom_components.teamtracker] Competitor information (BAR) not returned by API: http://site.api.espn.com/apis/site/v2/sports/soccer/esp.1/scoreboard
2022-10-08 11:24:16.475 DEBUG (MainThread) [custom_components.teamtracker] Finished fetching Fc Barcelona data in 15.637 seconds (success: True)
2022-10-08 11:24:16.479 DEBUG (MainThread) [custom_components.teamtracker] Did not find a game with for the configured team(LIV). Checking if it’s a bye week.
2022-10-08 11:24:16.480 DEBUG (MainThread) [custom_components.teamtracker] Competitor information (LIV) not returned by API: http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard
2022-10-08 11:24:16.482 DEBUG (MainThread) [custom_components.teamtracker] Finished fetching Liverpool data in 15.649 seconds (success: True)
2022-10-08 11:24:16.487 DEBUG (MainThread) [custom_components.teamtracker] Did not find a game with for the configured team(MNC ). Checking if it’s a bye week.
2022-10-08 11:24:16.488 DEBUG (MainThread) [custom_components.teamtracker] Competitor information (MNC ) not returned by API: http://site.api.espn.com/apis/site/v2/sports/soccer/eng.1/scoreboard
2022-10-08 11:24:16.490 DEBUG (MainThread) [custom_components.teamtracker] Finished fetching Manchester City data in 15.628 seconds (success: True)´

ok, for some reason, the abbreviation “MNC” was placed "MNC " with a space at the end, I see that this is the problem, however, one question, does the API return the information on the day of the match?

Each API returns games for a different number of days into the future. It seems like the EPL API only returns games for the current day.

I added a change in v0.4.0 so that if the state is NOT_FOUND, it will set the api_message attribute w/ more information about why it was not found. If the API returns info on any scheduled games, it will report the date range of the first and last game returned. If your game is in that window and it isn’t being found, there is a problem. If your game is outside that window, it just means the API isn’t returning information on it yet.

For example, since there is no game for LIV on 10/8, you should see it set to
api_message: No game scheduled for LIV between 2022-10-08T14:00Z and 2022-10-08T16:30Z

Other sports (i.e. NFL) return games a week in advance. It all depends on the API.

In any event, you helped me find a bug in my next release that I wouldn’t have found otherwise. Thanks.

thanks to you bro, very good job, since I started with HA, I always wanted an integration like this. I would like to give some ideas. I don’t know how possible.

  1. Add the Champions league.
  2. Show all the games of a team, regardless of the league, Friendly, Champions, Cups, etc.
  3. If the above is difficult because of the ESPN API, see if you can experiment with another provider.

Thank you very much for this integration.

I’ll add CL support in an upcoming release. In the meantime, you can add it with a custom API configuration. The Wiki actually has an example of the YAML but you can input the same info into the UI. If you enter XXX for the league, it will pop up a second window for the path information.

Unfortunately no easy way to track teams across leagues using ESPN APIs and the only other one I found was $$$. I get around the limitation it w/ a combo of conditional cards that groups multiple cards together and only displays if the state is not NOT_FOUND, for example.

v0.4.1 available

  • Added localization support
  • Added native support for the Champions League (CL)

Hopefully the dutch eredivsie will be availilble soon.

It supports the dutch eredivsie today. Just not natively.

You will have to set up a custom API configuration. Use ‘soccer’ as the sports_path and ‘ned.1’ as the league_path.

There are over 100 different soccer leagues which is too many to support them all natively. That’s why I enabled custom configurations, so if someone wanted one of them, there was a way to generate the API manually.

How does it determine whether to show pre, in, or post game stats?

Never mind, I see that ESPN determines that.

Firstly, Go Browns!

Forgive me if I missed a post on here, I have tried many different configurations but I can’t figure out the NBA Cavs abbreviation ( I tried CLE, cle but get the no game scheduled)

I did get all the nfl teams, guardians and the Ohio state buckeyes all working. I just need the NBA and I’ll be good to go.

Thanks in advance for any help.

Thanks!

Cirey

CLE should work. It is showing tonight’s Raptors game for me. It’s possible that the API wasn’t returning the game info yet and you just needed to wait. If you look at the api_message attribute on the sensor, if the team info isn’t found it will give more info as to why.

If you still have problems, post the sensor state and api_message and that will give more info to troubleshoot.

1 Like

yep, your correct. I’m sorry, i thought it would have been there this morning. all is good. Thanks for the work you have put into this! i appreciate it