Skip to content

Commit

Permalink
v0.8.0 Release Candidate (#101)
Browse files Browse the repository at this point in the history
* Require valid league_id's in YAML configurations
* Retain lap number in NASCAR races even if API doesn't return a value

NOTE:  Prior versions of teamtracker would allow invalid league_id's in YAML.  This version will not.  You must correct invalid values to pass the Configuration Test.
  • Loading branch information
vasqued2 authored May 27, 2023
1 parent 6524ef6 commit 39ae544
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/teamtracker/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@

# Misc
TEAM_ID = ""
VERSION = "v0.7.5"
VERSION = "v0.8.0"
ISSUE_URL = "https://github.com/vasqued2/ha-teamtracker"
DOMAIN = "teamtracker"
ATTRIBUTION = "Data provided by ESPN"
Expand Down
4 changes: 3 additions & 1 deletion custom_components/teamtracker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_LEAGUE_ID, default=DEFAULT_LEAGUE): vol.Upper,
vol.Required(CONF_LEAGUE_ID, default=DEFAULT_LEAGUE): vol.All(
vol.Upper, vol.In([*LEAGUE_MAP.keys(), "XXX"])
),
vol.Required(CONF_TEAM_ID): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): int,
Expand Down
18 changes: 16 additions & 2 deletions custom_components/teamtracker/set_racing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
from .utils import async_get_value

_LOGGER = logging.getLogger(__name__)

race_laps = {}

async def async_set_racing_values(
new_values, event, competition_index, team_index, lang, sensor_name
) -> bool:
"""Set racing specific values"""


#
# Pylint doesn't recognize values set by setdefault() method
#
global race_laps # pylint: disable=global-variable-not-assigned

# _LOGGER.debug("%s: async_set_racing_values() 0: %s", sensor_name, new_values)

if team_index == 0:
Expand Down Expand Up @@ -44,9 +50,17 @@ async def async_set_racing_values(
new_values["opponent_rank"] = oppo_index + 1
# _LOGGER.debug("%s: async_set_racing_values() 3: %s", sensor_name, new_values)

race_key = (
str(new_values["league"])
+ "-"
+ str(new_values["event_name"])
)
new_values["team_total_shots"] = await async_get_value(
competition, "status", "period"
competition, "status", "period",
default=race_laps.setdefault(race_key, 0),
)
race_laps.update({race_key: new_values["team_total_shots"]})

new_values["quarter"] = await async_get_value(competition, "type", "abbreviation")
# _LOGGER.debug("%s: async_set_racing_values() 4: %s", sensor_name, new_values)

Expand Down

0 comments on commit 39ae544

Please sign in to comment.