Skip to content

raphaelbleier/SpotifyToWled

Repository files navigation

SpotifyToWLED v2.0

Bring your music to life! SpotifyToWLED syncs the color palette of your Spotify album covers with your WLED LEDs for a vibrant, immersive experience.

✨ What's New in v2.1

  • πŸ” Fixed Docker Spotify authentication - No more "Address already in use" errors
  • πŸ”— OAuth callback route for seamless Spotify login in Docker/headless environments
  • πŸ’Ύ Token caching - No need to re-authenticate on every restart
  • 🏠 Home Assistant integration mode - Connect to external Docker servers
  • πŸ”„ Proxy mode for lightweight HA addon deployment
  • πŸ“ Enhanced documentation for all deployment scenarios

✨ What's New in v2.0

  • πŸ—οΈ Restructured codebase with proper modular architecture
  • 🎨 Modern web UI with Bootstrap 5 and real-time updates
  • ⚑ Performance improvements with caching and async operations
  • πŸ”§ Enhanced configuration management with validation
  • πŸ“Š Color history tracking and visualization
  • πŸ›‘οΈ Better error handling with automatic retries
  • πŸ” Multiple color extraction modes (vibrant, dominant, average)
  • πŸ’‘ Advanced WLED controls (brightness, effects)
  • πŸ“‘ Health monitoring for devices and API connections
  • πŸ“ Comprehensive logging for debugging
  • 🐳 Docker support with easy Portainer deployment
  • 🏠 Home Assistant add-on for seamless smart home integration

πŸš€ Quick Start

Choose your deployment method:

🐳 Docker (Recommended for Portainer)

Quick start:

docker run -d \
  --name spotifytowled \
  -p 5000:5000 \
  -v $(pwd)/config:/config \
  -v $(pwd)/data:/data \
  --restart unless-stopped \
  ghcr.io/raphaelbleier/spotifytowled:latest

Or with Docker Compose:

docker-compose up -d

πŸ“– Full Docker & Portainer Guide β†’

🏠 Home Assistant Add-on

  1. Add repository: https://github.com/raphaelbleier/SpotifyToWled
  2. Install SpotifyToWLED add-on
  3. Configure and start
  4. Open Web UI

πŸ“– Full Home Assistant Guide β†’

🐍 Python (Manual Installation)

Prerequisites:

  • Python 3.9 or higher
  • A Spotify Developer App (free): Create one here
  • One or more WLED devices on your network

Installation:

  1. Clone the repository:

    git clone https://github.com/raphaelbleier/SpotifyToWled.git
    cd SpotifyToWled
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the application:

    python run.py
  4. Open your browser and navigate to:

    http://localhost:5000
    
  5. Configure the application:

    • Get your Spotify credentials from Spotify Developer Dashboard
    • In Spotify Dashboard, add redirect URI: http://localhost:5000/callback (or your server IP)
    • Enter your Spotify Client ID and Client Secret
    • Click Save Configuration
    • Click Authenticate with Spotify button and log in
    • Add your WLED device IP addresses
    • Adjust refresh interval if needed
    • Choose your preferred color extraction method
  6. Start syncing and enjoy the light show! 🎢✨


🎯 Features

Color Extraction Modes

  • Vibrant (Recommended): Extracts the most saturated, vivid color from the album
  • Dominant: Uses the most prevalent color in the album art
  • Average: Calculates an average color from the palette

WLED Integration

  • Multiple device support
  • Device health monitoring
  • Brightness control
  • Effect selection
  • Automatic retry on connection failures

Web Interface

  • Real-time status updates
  • Color history visualization
  • Device management
  • Configuration management
  • Responsive design for mobile and desktop

πŸ“ Project Structure

SpotifyToWled/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ config.py          # Configuration management
β”‚   β”‚   └── sync_engine.py     # Main sync orchestrator
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ color_extractor.py # Color extraction with caching
β”‚   β”‚   β”œβ”€β”€ spotify_manager.py # Spotify API wrapper
β”‚   β”‚   └── wled_controller.py # WLED device controller
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── web.py             # Web routes and API endpoints
β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   β”œβ”€β”€ base.html          # Base template
β”‚   β”‚   └── index.html         # Main dashboard
β”‚   β”œβ”€β”€ static/
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”‚   └── style.css      # Custom styles
β”‚   β”‚   └── js/
β”‚   β”‚       └── app.js         # Client-side JavaScript
β”‚   └── main.py                # Application factory
β”œβ”€β”€ run.py                     # Application entry point
β”œβ”€β”€ requirements.txt           # Python dependencies
└── config.json               # Configuration file (auto-generated)

πŸ”§ Configuration

Configuration is stored in config.json (auto-generated on first run). You can also edit it directly:

{
  "SPOTIFY_CLIENT_ID": "your_client_id",
  "SPOTIFY_CLIENT_SECRET": "your_client_secret",
  "SPOTIFY_REDIRECT_URI": "http://localhost:5000/callback",
  "SPOTIFY_SCOPE": "user-read-currently-playing",
  "WLED_IPS": ["192.168.1.100", "192.168.1.101"],
  "REFRESH_INTERVAL": 30,
  "CACHE_DURATION": 5,
  "MAX_RETRIES": 3,
  "RETRY_DELAY": 2
}

🚒 Deployment Options

Docker & Portainer

Perfect for home servers and NAS devices. Includes health checks and automatic restarts.

  • Docker Deployment Guide - Complete guide for Docker and Portainer
  • Pre-built images available on GitHub Container Registry
  • Simple volume mapping for configuration persistence

Home Assistant

Native integration with Home Assistant supervisor.

  • Home Assistant Guide - Complete integration guide
  • Official add-on available
  • Ingress support for seamless UI access
  • Automation examples included

Manual Python

Traditional installation for development or custom setups.

  • Full control over environment
  • Easy debugging and development
  • See Quick Start section above

πŸ› Troubleshooting

Spotify Authentication Issues

  • Ensure your Client ID and Secret are correct
  • Check that the redirect URI matches: http://localhost:5000/callback
  • Make sure you've authorized the app in your browser

WLED Connection Problems

  • Verify WLED devices are on the same network
  • Check IP addresses are correct
  • Use the health check button to test connectivity
  • Ensure WLED firmware is up to date

Performance Issues

  • Increase the refresh interval for slower networks
  • Reduce the number of WLED devices
  • Clear the color cache if needed

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


πŸ™ Acknowledgments

  • WLED - Amazing LED control software
  • Spotipy - Spotify Web API wrapper
  • ColorThief - Color extraction library

Enjoy your synchronized light show! πŸŽ΅πŸ’‘βœ¨

About

Spotify Cover Color to Wled LEDs

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •