Skip to content

Commit

Permalink
v0.11.1 Release Candidate (#128)
Browse files Browse the repository at this point in the history
* Deprecate timeout configuration
* Minor code clean-up
  • Loading branch information
vasqued2 authored Jan 7, 2024
1 parent 9998fe5 commit ccce79c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion custom_components/teamtracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
CONF_LEAGUE_PATH,
CONF_SPORT_PATH,
CONF_TEAM_ID,
CONF_TIMEOUT,
COORDINATOR,
DEFAULT_KICKOFF_IN,
DEFAULT_LAST_UPDATE,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/teamtracker/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TeamTrackerScoresFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Config flow for TeamTracker."""

VERSION = 3
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL
# CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL

def __init__(self):
"""Initialize."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/teamtracker/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
CONF_LEAGUE_ID = "league_id"
CONF_LEAGUE_PATH = "league_path"
CONF_SPORT_PATH = "sport_path"
CONF_TIMEOUT = "timeout"
CONF_TEAM_ID = "team_id"

# Sports
Expand Down Expand Up @@ -180,6 +179,7 @@
)
DEFAULT_NAME = "team_tracker"
DEFAULT_PROB = 0.0
DEFAULT_SPORT_PATH = "UNDEFINED_SPORT"
DEFAULT_TIMEOUT = 120
DEFAULT_LAST_UPDATE = "2022-02-02 02:02:02-05:00"
DEFAULT_KICKOFF_IN = "{test} days"
Expand Down
16 changes: 9 additions & 7 deletions custom_components/teamtracker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
CONF_LEAGUE_PATH,
CONF_SPORT_PATH,
CONF_TEAM_ID,
CONF_TIMEOUT,
COORDINATOR,
DEFAULT_CONFERENCE_ID,
DEFAULT_ICON,
DEFAULT_LEAGUE,
DEFAULT_NAME,
DEFAULT_SPORT_PATH,
DOMAIN,
ISSUE_URL,
LEAGUE_MAP,
Expand All @@ -46,7 +46,6 @@
),
vol.Required(CONF_TEAM_ID): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TIMEOUT): int,
vol.Optional(CONF_CONFERENCE_ID, default=DEFAULT_CONFERENCE_ID): cv.string,
vol.Optional(CONF_API_LANGUAGE): cv.string,
vol.Optional(CONF_SPORT_PATH): cv.string,
Expand All @@ -71,9 +70,6 @@ async def async_setup_platform(
ISSUE_URL,
)

if CONF_TIMEOUT in config:
_LOGGER.warning("%s: Support for `timeout` in YAML config was deprecated in v0.11.0. Remove prior to next upgrade.", sensor_name)

league_ids = [*LEAGUE_MAP.keys(), "XXX"]
try:
vol.In(league_ids)(config[CONF_LEAGUE_ID])
Expand Down Expand Up @@ -166,11 +162,17 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Initialize the sensor."""
super().__init__(hass.data[DOMAIN][entry.entry_id][COORDINATOR])

sport_path = entry.data[CONF_SPORT_PATH]
sport_path = entry.data.get(CONF_SPORT_PATH, DEFAULT_SPORT_PATH)
if sport_path == DEFAULT_SPORT_PATH:
_LOGGER.debug(
"%s: Initializing sensor values. SPORT_PATH not set.",
entry.data[CONF_NAME],
)

icon = SPORT_ICON_MAP.get(sport_path, DEFAULT_ICON)
if icon == DEFAULT_ICON:
_LOGGER.debug(
"%s: Setting up sensor from YAML. Sport '%s' not found.",
"%s: Initializing sensor values. Sport icon not found for sport '%s'",
entry.data[CONF_NAME],
sport_path,
)
Expand Down

0 comments on commit ccce79c

Please sign in to comment.