Files
ledgrab/server
alexei.dolgolyov 56853b7123 feat(dashboard): per-account customizable dashboard with slide-in panel
Open-registry section/perf-cell schema persisted server-side under
db.get_setting('dashboard_layout'); localStorage cache for instant
first-paint, server sync after auth. 5 built-in presets
(Studio/Operator/Showrunner/Diagnostics/TV); JSON export/import.

Slide-in Customize panel toggles section + perf-cell visibility,
reorders via hand-rolled HTML5 drag (with up/down buttons for
keyboard/TV-remote use), changes density per section, and exposes
global Width / Animations / Perf-mode / Window with per-cell Inherit
overrides.

Window setting now drives the actual sparkline slice (30s/1m/2m/5m at
configurable poll interval) instead of always rendering 120 fixed
samples. Perf-grid edits re-render in place — sparklines repaint from
persistent module-level history, value labels replay from cached
last-fetch payload, so there is no flicker frame and no zero-data
window between layout change and next poll. initPerfCharts now fires
an immediate fetch on init so reload no longer shows "—" until the
first interval tick.

Reset confirmation uses the project's themed showConfirm modal
instead of the browser dialog. Reserved registry keys (audio-meters,
alerts, led-preview, source-thumbs, pinned, flow) are forward-
compatible so v1.1 cards slot in without a schema bump.

Backend exposes GET/PUT/DELETE /api/v1/preferences/dashboard-layout
treating the body as opaque JSON with a numeric version gate; covered
by 6 round-trip / validation / unknown-field tests.
2026-04-25 01:43:14 +03:00
..
2026-04-22 19:48:37 +03:00

LedGrab - Server

High-performance FastAPI server that captures screen content and controls WLED devices for ambient lighting.

Overview

The server component provides:

  • 🎯 Real-time Screen Capture - Multi-monitor support with configurable FPS
  • 🎨 Advanced Processing - Border pixel extraction with color correction
  • 🔧 Flexible Calibration - Map screen edges to any LED layout
  • 🌐 REST API - Complete control via 25+ REST endpoints
  • 💾 Persistent Storage - JSON-based device and configuration management
  • 📊 Metrics & Monitoring - Real-time FPS, status, and performance data

Quick Start

# Start server
docker-compose up -d

# View logs
docker-compose logs -f

# Stop server
docker-compose down

Server runs on: http://localhost:8080

Option 2: Python

# Create virtual environment
python -m venv venv

# Activate
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate      # Windows

# Install dependencies
pip install .

# Set PYTHONPATH
export PYTHONPATH=$(pwd)/src  # Linux/Mac
set PYTHONPATH=%CD%\src       # Windows

# Run server
uvicorn ledgrab.main:app --host 0.0.0.0 --port 8080

Installation

Requirements

  • Python 3.11+ (for Python installation)
  • Docker & Docker Compose (for Docker installation)
  • WLED device on your network

See ../INSTALLATION.md for comprehensive installation guide.

Configuration

Configuration File

Edit config/default_config.yaml:

server:
  host: "0.0.0.0"
  port: 8080
  log_level: "INFO"

processing:
  default_fps: 30        # Target frames per second
  max_fps: 60           # Maximum allowed FPS
  border_width: 10      # Pixels to sample from edge

wled:
  timeout: 5            # Connection timeout (seconds)
  retry_attempts: 3     # Number of retries

storage:
  devices_file: "data/devices.json"

logging:
  format: "json"
  file: "logs/ledgrab.log"

Environment Variables

# Server configuration
export LEDGRAB_SERVER__HOST="0.0.0.0"
export LEDGRAB_SERVER__PORT=8080
export LEDGRAB_SERVER__LOG_LEVEL="INFO"

# Processing configuration
export LEDGRAB_PROCESSING__DEFAULT_FPS=30
export LEDGRAB_PROCESSING__BORDER_WIDTH=10

# WLED configuration
export WLED_WLED__TIMEOUT=5

Usage

WLED Device Setup

Important: Configure your WLED device using the official WLED web interface before connecting it to this controller:

  1. Access WLED Interface: Open http://[wled-ip] in your browser
  2. Configure Device Settings:
    • Set LED count and type
    • Configure brightness, color order, and power limits
    • Set up segments if needed
    • Configure effects and presets

This controller only sends pixel color data - it does not manage WLED settings like brightness, effects, or segments. All WLED device configuration should be done through the official WLED interface.

API Documentation

Quick Example

# 1. Add device
curl -X POST http://localhost:8080/api/v1/devices \
  -H "Content-Type: application/json" \
  -d '{"name":"Living Room","url":"http://192.168.1.100","led_count":150}'

# 2. Start processing
curl -X POST http://localhost:8080/api/v1/devices/{device_id}/start

# 3. Check status
curl http://localhost:8080/api/v1/devices/{device_id}/state

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=ledgrab --cov-report=html

# Run specific test
pytest tests/test_screen_capture.py -v

Development

Project Structure

src/ledgrab/
├── main.py              # FastAPI application
├── config.py            # Configuration
├── api/                 # API routes
├── core/                # Core functionality
│   ├── screen_capture.py
│   ├── wled_client.py
│   ├── calibration.py
│   └── processor_manager.py
├── storage/             # Data persistence
└── utils/               # Utilities

Code Quality

# Format code
black src/ tests/

# Lint code
ruff check src/ tests/

License

MIT - see ../LICENSE

Support