Skip to content

Add sports-score-alert: proactive game alerts with comeback detection#285

Closed
hassan1731996 wants to merge 3 commits into
openhome-dev:devfrom
hassan1731996:feature/sports-score-alert
Closed

Add sports-score-alert: proactive game alerts with comeback detection#285
hassan1731996 wants to merge 3 commits into
openhome-dev:devfrom
hassan1731996:feature/sports-score-alert

Conversation

@hassan1731996

Copy link
Copy Markdown
Contributor

What this adds

A proactive sports daemon that watches your followed teams and interrupts you when something actually happens — not when you remember to ask.

Supported sports & APIs

  • NFL, NBA, MLB, NHL, global soccer — ESPN unofficial API (no key, no auth)
  • Cricket — CricAPI (user-supplied key, 100 req/day free)

Alert types

Event When
Pre-match 30 minutes before kickoff
Game start The moment the match begins
Score update Every new score, keyed by score_{a}-{b} to deduplicate
Comeback When the gap closes ≥10 points/runs/goals
Halftime Detected from ESPN status detail string
Final result Fires once when state flips to post

All spoken alerts are LLM-composed with match context — not just the number.

Smart polling

POLL_LIVE     = 60s   (active game in progress)
POLL_PREMATCH = 300s  (game starting within 2 hours)
POLL_IDLE     = 1800s (no games today)

The daemon recomputes sleep time every loop — idle weekdays don't burn API quota.

What Alexa can't do

Alexa reports scores on-demand. This daemon fires when your team scores, detects comebacks, and tells you the result the moment the game ends — with spoken context like "Lakers on a 12-2 run, 98-91 with 4 minutes left."

Validation

✅ All checks passed

No print(), asyncio.sleep(), asyncio.create_task(), open(), assert, or hardcoded keys.

… with comeback detection

Watches followed teams across NFL, NBA, MLB, NHL, soccer, and cricket and fires
voice interrupts for pre-match, game start, score changes, comebacks, halftime, and
final results. Smart polling: 60s live, 300s pre-game, 1800s idle. Event deduplication
via game-id + alert-type in persistent KV store.
@hassan1731996 hassan1731996 requested a review from a team as a code owner June 24, 2026 17:02
@github-actions

Copy link
Copy Markdown
Contributor

✅ Community PR Path Check — Passed

All changed files are inside the community/ folder. Looks good!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Ability Validation Passed

📋 Validating: community/sports-score-alert
  ✅ All checks passed!

@github-actions

Copy link
Copy Markdown
Contributor

🔀 Branch Merge Check

PR direction: feature/sports-score-alertdev

Passedfeature/sports-score-alertdev is a valid merge direction

@github-actions github-actions Bot added the community-ability Community-contributed ability label Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🔍 Lint Results

__init__.py — Empty as expected

Files linted: community/sports-score-alert/background.py community/sports-score-alert/main.py

✅ Flake8 — Passed

✅ All checks passed!

@abubakar4360

abubakar4360 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Hi @hassan1731996, please share the demo video.

@hassan1731996

hassan1731996 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Hey @abubakar4360, recorded a live test on the editor - here's the video: https://mega.nz/file/3Qc2kKqD#5xkg5p99mWGs3OjmWB-gHzQopkfo2EEytKYxE3FYFRY

Ran through the full flow: follow multiple teams (Yankees, Red Sox, Inter Miami), live scores, upcoming schedule, recent results, and unfollow with confirmation. All working on real ESPN data.

Also created a new PR with all the latest fixes: #289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-ability Community-contributed ability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants