Skip to content

feat: next_games attribute, team_season_stats, score_change event, ad…#273

Open
duczz wants to merge 8 commits intovasqued2:masterfrom
duczz:feat/new-features
Open

feat: next_games attribute, team_season_stats, score_change event, ad…#273
duczz wants to merge 8 commits intovasqued2:masterfrom
duczz:feat/new-features

Conversation

@duczz
Copy link
Copy Markdown

@duczz duczz commented Mar 16, 2026

…aptive polling

next_games — upcoming schedule

New sensor attribute: array of up to 3 upcoming games extracted from the existing 90-day scoreboard response (no extra API call).

next_games:
  - date: "2026-03-15T19:00:00Z" event_name: "Celtics at Lakers" opponent: "Los Angeles Lakers" opponent_abbr: "LAL" opponent_logo: "https://..." home_away: "away" venue: "Crypto.com Arena"

team_season_stats — season statistics

New sensor attribute: season record fetched from ESPN's Teams API with a 6-hour instance cache (no repeated calls). Disabled for Golf, Racing, Tennis, and MMA. Uses the numeric ESPN team ID from coordinator data (not the abbreviation) to avoid silent 404s.

team_season_stats:
  wins: 42
  losses: 20
  win_streak: 3
  points_per_game: 112.3

teamtracker.score_change — HA event

Fires a Home Assistant event during live games (state == "IN") whenever the team or opponent score changes. Enables score-based automations without polling sensor state. Score-initialized flag prevents a false event on the second coordinator update.

entity_id: sensor.my_team
team_name: "FC Bayern München"
team_score: "2"
opponent_score: "1"
prev_team_score: "1"
prev_opponent_score: "1"

Adaptive polling (4 levels)

Reduces unnecessary API calls outside of live games:

IN / PRE < 20 min before kickoff  →  5 s (unchanged)
PRE > 20 min before kickoff       →  10 min (unchanged)
POST (game finished)              →  2 min  (new)
NOT_FOUND / offseason             →  30 min (new)

Stale-data fallback

On API error the last known data is reused instead of immediately switching to NOT_FOUND, preventing false automation triggers during brief connectivity issues. api_message is set to
"Stale data (API unavailable)" when serving stale data.

Note: this branch also includes the bugfixes from fix/bugfixes (session leak, cache None, fromisoformat date parse, last_update recorder growth) as they were developed together. If fix/bugfixes is merged first this branch can be rebased cleanly.

duczz and others added 6 commits April 14, 2026 07:44
…aptive polling

New sensor attribute: array of up to 3 upcoming games extracted from the
existing 90-day scoreboard response (no extra API call).

    next_games:
      - date: "2026-03-15T19:00:00Z"
        event_name: "Celtics at Lakers"
        opponent: "Los Angeles Lakers"
        opponent_abbr: "LAL"
        opponent_logo: "https://..."
        home_away: "away"
        venue: "Crypto.com Arena"

New sensor attribute: season record fetched from ESPN's Teams API with a
6-hour instance cache (no repeated calls). Disabled for Golf, Racing,
Tennis, and MMA. Uses the numeric ESPN team ID from coordinator data
(not the abbreviation) to avoid silent 404s.

    team_season_stats:
      wins: 42
      losses: 20
      win_streak: 3
      points_per_game: 112.3

Fires a Home Assistant event during live games (state == "IN") whenever
the team or opponent score changes. Enables score-based automations
without polling sensor state. Score-initialized flag prevents a false
event on the second coordinator update.

    entity_id: sensor.my_team
    team_name: "FC Bayern München"
    team_score: "2"
    opponent_score: "1"
    prev_team_score: "1"
    prev_opponent_score: "1"

Reduces unnecessary API calls outside of live games:

    IN / PRE < 20 min before kickoff  →  5 s (unchanged)
    PRE > 20 min before kickoff       →  10 min (unchanged)
    POST (game finished)              →  2 min  (new)
    NOT_FOUND / offseason             →  30 min (new)

On API error the last known data is reused instead of immediately
switching to NOT_FOUND, preventing false automation triggers during
brief connectivity issues. api_message is set to
"Stale data (API unavailable)" when serving stale data.

Note: this branch also includes the bugfixes from fix/bugfixes
(session leak, cache None, fromisoformat date parse, last_update
recorder growth) as they were developed together. If fix/bugfixes
is merged first this branch can be rebased cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@duczz duczz force-pushed the feat/new-features branch from 53158df to 9e7310c Compare April 14, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant