feat: next_games attribute, team_season_stats, score_change event, ad…#273
Open
duczz wants to merge 8 commits intovasqued2:masterfrom
Open
feat: next_games attribute, team_season_stats, score_change event, ad…#273duczz wants to merge 8 commits intovasqued2:masterfrom
duczz wants to merge 8 commits intovasqued2:masterfrom
Conversation
…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>
…ng BOS POST state
53158df to
9e7310c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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).
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.
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.
Adaptive polling (4 levels)
Reduces unnecessary API calls outside of live games:
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.