npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

homebridge-game-light

v1.0.0

Published

A Homebridge plugin that creates a switch to trigger HomeKit automations when your favorite NBA team plays.

Readme


🏀 What It Does

Game Light monitors sports schedules and creates a switch in HomeKit that automatically turns ON when your team's game starts and OFF when it ends.

You then create HomeKit automations to control your actual lights:

  • Game starts → Living room turns to team color
  • Game ends → Living room returns to normal

This approach lets you use any lights already in your HomeKit setup (Hue, LIFX, Nanoleaf, etc.).

Currently Supported: NBA Basketball
More sports coming soon! See Future Extensibility.

✨ Features

  • 🏀 Track your favorite team
  • ⏱️ Smart polling with increased frequency in final minutes
  • 🔄 Automatic game detection from official schedules
  • 🎮 Manual switch toggle for testing
  • 📊 Robust API rate limiting and retry logic

📦 Installation

Via Homebridge UI (Recommended)

  1. Open the Homebridge UI
  2. Go to Plugins tab
  3. Search for homebridge-game-light
  4. Click Install

Via Command Line

npm install -g homebridge-game-light

⚙️ Configuration

Via Homebridge UI

  1. Go to PluginsGame LightSettings
  2. Select your sport and team
  3. Save and restart Homebridge

Manual Configuration

Add to your config.json:

{
  "platforms": [
    {
      "platform": "GameLight",
      "name": "Game Light",
      "sport": "NBA",
      "team": "BOS",
      "pollingInterval": 5,
      "scheduleCheckInterval": 6
    }
  ]
}

Configuration Options

| Option | Description | Default | |--------|-------------|---------| | sport | Sport league (NBA) | NBA | | team | Team abbreviation (e.g., BOS, LAL, GSW) | BOS | | pollingInterval | Minutes between game status checks during a game | 5 | | scheduleCheckInterval | Hours between schedule checks when idle | 6 |

NBA Teams & Colors

Use these Hue (H) and Saturation (S) values when setting up your HomeKit light automations. In the Home app color picker, set the hue angle and saturation percentage to match.

Eastern Conference

| Code | Team | Primary | H° / S% | Secondary | H° / S% | |------|------|---------|---------|-----------|---------| | ATL | Atlanta Hawks | Hawks Red | 358 / 74 | Volt Green | 68 / 65 | | BOS | Boston Celtics | Celtics Green | 145 / 100 | Gold | 38 / 36 | | BKN | Brooklyn Nets | Black | 0 / 0 | White | 0 / 0 | | CHA | Charlotte Hornets | Hornets Purple | 256 / 79 | Teal | 187 / 100 | | CHI | Chicago Bulls | Bulls Red | 350 / 87 | Black | 0 / 0 | | CLE | Cleveland Cavaliers | Wine | 341 / 100 | Gold | 43 / 97 | | DET | Detroit Pistons | Red | 350 / 82 | Royal Blue | 224 / 78 | | IND | Indiana Pacers | Pacers Blue | 214 / 100 | Gold | 43 / 97 | | MIA | Miami Heat | Heat Red | 345 / 100 | Orange | 37 / 93 | | MIL | Milwaukee Bucks | Good Land Green | 145 / 100 | Cream City Cream | 42 / 67 | | NYK | New York Knicks | Knicks Blue | 207 / 100 | Orange | 24 / 92 | | ORL | Orlando Magic | Magic Blue | 202 / 100 | Black | 0 / 0 | | PHI | Philadelphia 76ers | Royal Blue | 207 / 100 | Red | 348 / 84 | | TOR | Toronto Raptors | Raptors Red | 348 / 89 | Black | 0 / 0 | | WAS | Washington Wizards | Navy Blue | 214 / 100 | Red | 351 / 82 |

Western Conference

| Code | Team | Primary | H° / S% | Secondary | H° / S% | |------|------|---------|---------|-----------|---------| | DAL | Dallas Mavericks | Royal Blue | 207 / 100 | Navy Blue | 210 / 100 | | DEN | Denver Nuggets | Midnight Blue | 214 / 65 | Sunshine Yellow | 47 / 98 | | GSW | Golden State Warriors | Warriors Blue | 220 / 66 | Golden Yellow | 45 / 100 | | HOU | Houston Rockets | Rockets Red | 348 / 89 | Black | 0 / 0 | | LAC | LA Clippers | Clippers Red | 350 / 82 | Blue | 220 / 66 | | LAL | Los Angeles Lakers | Lakers Purple | 270 / 56 | Gold | 44 / 97 | | MEM | Memphis Grizzlies | Beale Street Blue | 221 / 34 | Navy Blue | 229 / 56 | | MIN | Minnesota Timberwolves | Midnight Blue | 214 / 66 | Lake Blue | 205 / 57 | | NOP | New Orleans Pelicans | Pelicans Navy | 214 / 66 | Red | 350 / 82 | | OKC | Oklahoma City Thunder | Thunder Blue | 200 / 100 | Sunset Orange | 11 / 86 | | PHX | Phoenix Suns | Suns Purple | 256 / 79 | Orange | 22 / 78 | | POR | Portland Trail Blazers | Blazers Red | 358 / 74 | Black | 0 / 0 | | SAC | Sacramento Kings | Kings Purple | 275 / 52 | Black | 0 / 0 | | SAS | San Antonio Spurs | Silver | 0 / 6 | Black | 0 / 0 | | UTA | Utah Jazz | Navy Blue | 214 / 100 | Green | 145 / 100 |

Tip: In the Home app, tap a light → tap the color wheel → use Hue (angle around the wheel) and Saturation (distance from center).

🏠 Setting Up HomeKit Automations

After installing and configuring the plugin, you'll see a switch named after your team (e.g., "Boston Celtics Game") in the Home app.

Create "Game Start" Automation

  1. Open the Home app
  2. Tap Automation+Add Automation
  3. Choose An Accessory is Controlled
  4. Select your team's switch → Turns On
  5. Add actions:
    • Set your lights to your team's color
    • Set Brightness to 100%
  6. Tap Done

Create "Game End" Automation

  1. Tap +Add Automation
  2. Choose An Accessory is Controlled
  3. Select your team's switch → Turns Off
  4. Add actions to set your lights back to normal
  5. Tap Done

🛠️ Development

# Clone the repository
git clone https://github.com/adamkornafeld/homebridge-game-light.git
cd game-light

# Install dependencies
npm install

# Build
npm run build

# Link for local testing
npm link

# Run Homebridge with debug logging
homebridge -D

Testing the API

# Test API connection
npx tsx scripts/testApi.ts

📋 How It Works

  1. Schedule Check: Plugin checks schedule for your team's games
  2. Game Detection: When a game is found, switches to active polling
  3. Game Start: When game status changes to "live", turns switch ON
  4. Smart Polling: In final minutes, polls more frequently for accuracy
  5. Game End: When game ends, turns switch OFF
  6. Idle: Returns to infrequent schedule checks
Schedule Check (every 6h)
        │
        ▼
   Game Found? ──No──→ Wait & Retry
        │
       Yes
        ▼
   Poll Game (every 5m)
        │
        ▼
   Game Started? ──No──→ Wait & Retry
        │
       Yes
        ▼
   🏀 Switch ON ──→ HomeKit Automation
        │
        ▼
   Final minutes? ──Yes──→ Poll every 30s
        │
        ▼
   Game Ended?
        │
       Yes
        ▼
   🏁 Switch OFF ──→ HomeKit Automation

⚠️ API Rate Limiting

This plugin uses public sports APIs which may have rate limiting. The plugin includes:

  • Exponential backoff with jitter
  • Retry-After header support
  • Minimum request intervals
  • Graceful degradation on errors

If you see 429 errors in the logs, the plugin will automatically back off and retry.

🚀 Future Extensibility

| Feature | Description | |---------|-------------| | NHL Support | Add NHL API client, team data | | NFL Support | Add ESPN/NFL API | | MLB Support | Add MLB Stats API | | Multi-team | Support multiple teams (flash alternating colors) | | Score alerts | Flash lights on scoring plays | | Win celebration | Special color effect when your team wins | | Away game colors | Option to show opponent's color for away games | | Pre-game countdown | Gradual color transition before tip-off |

Want to contribute? PRs welcome!

🙏 Acknowledgments

⚖️ Disclaimer

This project is not affiliated with, endorsed by, or connected to the National Basketball Association (NBA) or any of its member teams.

NBA, the NBA logo, and all NBA team names, logos, and related marks are registered trademarks of NBA Properties, Inc. and the respective NBA member teams. All other trademarks are the property of their respective owners.

Team colors provided in this plugin are approximations for personal, non-commercial home automation use only. This is an independent, open-source project created for fans to enhance their game-watching experience.

Use of the NBA API is subject to the NBA's terms of service. This plugin accesses only publicly available game schedule data.