From 1722cf1ed923fb0d3bb043dfcee30841c1db14d6 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 17:34:53 -0400 Subject: [PATCH] Release Candidate 9.0 (#109) - Added native support for Women's World Cup (WWC) - Allowed use of ESPN's unique team_id number to identify teams in addition to team abbreviations - Updated documentation to clarify values to use for team_id --- README.md | 17 +++++++++++++++-- custom_components/teamtracker/const.py | 6 +++++- custom_components/teamtracker/event.py | 12 ++++++++++++ tests/const.py | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d143513..c4e8e69 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The following leagues are supported natively: - Hockey - NHL - MMA - UFC - U.S. Soccer - MLS, NWSL -- International Soccer - BUND (German Bundesliga), CL (Champions League), EPL (English Premiere League), LIGA (Spanish LaLiga), LIG1 (French Ligue 1), SERA (Italian Serie A), WC (World Cup) +- International Soccer - BUND (German Bundesliga), CL (Champions League), EPL (English Premiere League), LIGA (Spanish LaLiga), LIG1 (French Ligue 1), SERA (Italian Serie A), WC (World Cup), WWC (Women's World Cup) - Racing - F1, IRL - Tennis - ATP, WTA - Volleyball - NCAAVB, NCAAVBW @@ -149,10 +149,21 @@ type: Javascript Module ### Configuration via the "Configuration->Integrations" section of the Home Assistant UI -Search for the integration labeled "Team Tracker" and select it. Enter the desired League from the League List below and your team's ID in the UI prompt. If NCAA football or basketball, enter the Conference ID from Conference ID Numbers below if desired. You can also enter a friendly name. If you keep the default, your sensor will be `sensor.team_tracker`, otherwise it will be `sensor.friendly_name_you_picked`. +1. Search for the integration labeled "Team Tracker" and select it. +2. Enter the desired League from the League List. +3. Enter the team's ID in the UI prompt. +4. If NCAA football or basketball, enter the Conference ID from Conference ID Numbers below if desired. +5. You can also enter a friendly name. If you keep the default, your sensor will be `sensor.team_tracker`, otherwise it will be `sensor.friendly_name_you_picked`. When using the Home Assistant UI to set up a Custom API Configuration, simply enter 'XXX' in the League field. This will trigger a second dialogue box which will allow you to enter the values for the {SPORT_PATH} and {LEAGUE_PATH}. +#### Determining the Team ID +For the Team ID, you'll need to know the team abbreviation ESPN uses for your team. This is the 2-, 3- or 4-letter abbreviation (eg. "SEA" for Seattle or "NE" for New England) ESPN uses when space is limited. You can generally find them at https://espn.com/ in the top scores UI, but they can also be found in other pages with team stats as well. + +Alternate Method: ESPN assigns a unique number to identify a team. This unique number shows up in URLs and other locations. This value can also be used to specify the team ID. If used, TeamTracker will also search for this number to uniquely identify a team. + +For sports involving individual athletes, you should use the athlete's name as the search string. You should use as much as is needed to uniquely identify the desired athlete. + #### Use of a Wild Card In Place of Athlete's Name You can use the single `*` character as a Wild Card in place of the team or athlete's name. This will cause the sensor to match a team or athlete using sport-specific logic. @@ -239,6 +250,8 @@ For the League, the following values are valid: - WTA (Women's Tennis Assc.) - XXX (Custom API Configuration) +### Team ID + For the Team, you'll need to know the team ID ESPN uses for your team. This is the 2-, 3- or 4-letter abbreviation (eg. "SEA" for Seattle or "NE" for New England) ESPN uses when space is limited. You can generally find them at https://espn.com/ in the top scores UI, but they can also be found in other pages with team stats as well. NOTE: In rare instances, the team ID will vary based on your local language. While rare, changing the language after a sensor is set up can cause it to stop working. diff --git a/custom_components/teamtracker/const.py b/custom_components/teamtracker/const.py index 9df073b..8f5645c 100644 --- a/custom_components/teamtracker/const.py +++ b/custom_components/teamtracker/const.py @@ -131,6 +131,10 @@ CONF_SPORT_PATH: SOCCER, CONF_LEAGUE_PATH: "fifa.world", }, + "WWC": { + CONF_SPORT_PATH: SOCCER, + CONF_LEAGUE_PATH: "fifa.wwc", + }, "ATP": { CONF_SPORT_PATH: TENNIS, CONF_LEAGUE_PATH: "atp", @@ -180,7 +184,7 @@ # Misc TEAM_ID = "" -VERSION = "v0.8.1" +VERSION = "v0.9.0" ISSUE_URL = "https://github.com/vasqued2/ha-teamtracker" DOMAIN = "teamtracker" ATTRIBUTION = "Data provided by ESPN" diff --git a/custom_components/teamtracker/event.py b/custom_components/teamtracker/event.py index fb03537..0cd76f2 100644 --- a/custom_components/teamtracker/event.py +++ b/custom_components/teamtracker/event.py @@ -206,6 +206,18 @@ async def async_find_search_key( ) return team_index + team_id = str(await async_get_value( + competitor, "team", "id", default="" + )) + + if search_key == team_id: + _LOGGER.debug( + "%s: Found competition for team '%s' in team id; parsing data.", + sensor_name, + search_key, + ) + return team_index + # Abbreviations in event_name can be different than team_abbr so look there if neither team abbrevations match team0_abbreviation = str( await async_get_value( diff --git a/tests/const.py b/tests/const.py index 1b31e4d..c969e9b 100644 --- a/tests/const.py +++ b/tests/const.py @@ -111,7 +111,7 @@ "sensor_name": "test_tt_all_test16", "sport": "volleyball", "league": "NCAAVBW", - "team_abbr": "PEPP", + "team_abbr": "2492", #PEPP }, { "sensor_name": "test_tt_all_test17",