Security: tighten CORS defaults, add webhook rate limiting, fix XSS in automations, guard WebSocket JSON.parse, validate ADB address input, seal debug exception leak, URL-encode WS tokens, CSS.escape in selectors. Code quality: add Pydantic models for brightness/power endpoints, fix thread safety and name uniqueness in DeviceStore, immutable update pattern, split 6 oversized files into 16 focused modules, enable TypeScript strictNullChecks (741→102 errors), type state variables, add dom-utils helper, migrate 3 modules from inline onclick to event delegation, ProcessorDependencies dataclass. Performance: async store saves, health endpoint log level, command palette debounce, optimized entity-events comparison, fix service worker precache list. Testing: expand from 45 to 293 passing tests — add store tests (141), route tests (25), core logic tests (42), E2E flow tests (33), organize into tests/api/, tests/storage/, tests/core/, tests/e2e/. DevOps: CI test pipeline, pre-commit config, Dockerfile multi-stage build with non-root user and health check, docker-compose improvements, version bump to 0.2.0. Docs: rewrite CLAUDE.md (202→56 lines), server/CLAUDE.md (212→76), create contexts/server-operations.md, fix .js→.ts references, fix env var prefix in README, rewrite INSTALLATION.md, add CONTRIBUTING.md and .env.example.
8.6 KiB
Installation Guide
Complete installation guide for LED Grab (WLED Screen Controller) server and Home Assistant integration.
Table of Contents
- Docker Installation (recommended)
- Manual Installation
- First-Time Setup
- Home Assistant Integration
- Configuration Reference
- Troubleshooting
Docker Installation
The fastest way to get running. Requires Docker with Compose.
-
Clone and start:
git clone https://git.dolgolyov-family.by/alexei.dolgolyov/wled-screen-controller-mixed.git cd wled-screen-controller/server docker compose up -d -
Verify:
curl http://localhost:8080/health # → {"status":"healthy", ...} -
Open the dashboard: http://localhost:8080
-
View logs:
docker compose logs -f -
Stop / restart:
docker compose down # stop docker compose up -d # start again (data is persisted)
Docker manual build (without Compose)
cd server
docker build -t ledgrab .
docker run -d \
--name wled-screen-controller \
-p 8080:8080 \
-v $(pwd)/data:/app/data \
-v $(pwd)/logs:/app/logs \
-v $(pwd)/config:/app/config:ro \
ledgrab
Linux screen capture in Docker
Screen capture from inside a container requires X11 access. Uncomment network_mode: host in docker-compose.yml and ensure the DISPLAY variable is set. Wayland is not currently supported for in-container capture.
Manual Installation
Requirements
| Dependency | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Backend server |
| Node.js | 18+ | Frontend build (esbuild) |
| pip | latest | Python package installer |
| npm | latest | Node package manager |
Steps
-
Clone the repository:
git clone https://git.dolgolyov-family.by/alexei.dolgolyov/wled-screen-controller-mixed.git cd wled-screen-controller/server -
Build the frontend bundle:
npm ci npm run buildThis compiles TypeScript and bundles JS/CSS into
src/wled_controller/static/dist/. -
Create a virtual environment:
python -m venv venv # Linux / macOS source venv/bin/activate # Windows (cmd) venv\Scripts\activate # Windows (PowerShell) venv\Scripts\Activate.ps1 -
Install Python dependencies:
pip install .Optional extras:
pip install ".[camera]" # Webcam capture via OpenCV pip install ".[perf]" # DXCam, BetterCam, WGC (Windows only) pip install ".[notifications]" # OS notification capture pip install ".[dev]" # pytest, black, ruff (development) -
Set PYTHONPATH and start the server:
# Linux / macOS export PYTHONPATH=$(pwd)/src uvicorn wled_controller.main:app --host 0.0.0.0 --port 8080 # Windows (cmd) set PYTHONPATH=%CD%\src uvicorn wled_controller.main:app --host 0.0.0.0 --port 8080 -
Verify: open http://localhost:8080 in your browser.
First-Time Setup
Change the default API key
The server ships with a development API key (development-key-change-in-production). Change it before exposing the server on your network.
Option A -- edit the config file:
# server/config/default_config.yaml
auth:
api_keys:
main: "your-secure-key-here" # replace the dev key
Option B -- set an environment variable:
export WLED_AUTH__API_KEYS__main="your-secure-key-here"
Generate a random key:
openssl rand -hex 32
Configure CORS for LAN access
By default the server only allows requests from http://localhost:8080. To access the dashboard from another machine on your LAN, add its origin:
# server/config/default_config.yaml
server:
cors_origins:
- "http://localhost:8080"
- "http://192.168.1.100:8080" # your server's LAN IP
Or via environment variable:
WLED_SERVER__CORS_ORIGINS='["http://localhost:8080","http://192.168.1.100:8080"]'
Discover devices
Open the dashboard and go to the Devices tab. Click Discover to find WLED devices on your network via mDNS. You can also add devices manually by IP address.
Home Assistant Integration
Option 1: HACS (recommended)
- Install HACS if you have not already.
- Open HACS in Home Assistant.
- Click the three-dot menu, then Custom repositories.
- Add URL:
https://git.dolgolyov-family.by/alexei.dolgolyov/wled-screen-controller-mixed - Set category to Integration and click Add.
- Search for "WLED Screen Controller" in HACS and click Download.
- Restart Home Assistant.
- Go to Settings > Devices & Services > Add Integration and search for "WLED Screen Controller".
- Enter your server URL (e.g.,
http://192.168.1.100:8080) and API key.
Option 2: Manual
Copy the custom_components/wled_screen_controller/ folder from this repository into your Home Assistant config/custom_components/ directory, then restart Home Assistant and add the integration as above.
Automation example
automation:
- alias: "Start ambient lighting when TV turns on"
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: "on"
action:
- service: switch.turn_on
target:
entity_id: switch.living_room_tv_processing
- alias: "Stop ambient lighting when TV turns off"
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: "off"
action:
- service: switch.turn_off
target:
entity_id: switch.living_room_tv_processing
Configuration Reference
The server reads configuration from three sources (in order of priority):
- Environment variables -- prefix
WLED_, double underscore as nesting delimiter (e.g.,WLED_SERVER__PORT=9090) - YAML config file --
server/config/default_config.yaml(or setWLED_CONFIG_PATHto override) - Built-in defaults
See server/.env.example for every available variable with descriptions.
Key settings
| Variable | Default | Description |
|---|---|---|
WLED_SERVER__PORT |
8080 |
HTTP listen port |
WLED_SERVER__LOG_LEVEL |
INFO |
DEBUG, INFO, WARNING, ERROR |
WLED_SERVER__CORS_ORIGINS |
["http://localhost:8080"] |
Allowed CORS origins (JSON array) |
WLED_AUTH__API_KEYS |
{"dev":"development-key..."} |
API keys (JSON object) |
WLED_MQTT__ENABLED |
false |
Enable MQTT for HA auto-discovery |
WLED_MQTT__BROKER_HOST |
localhost |
MQTT broker address |
WLED_DEMO |
false |
Enable demo mode (sandbox with virtual devices) |
Troubleshooting
Server will not start
Check Python version:
python --version # must be 3.11+
Check the frontend bundle exists:
ls server/src/wled_controller/static/dist/app.bundle.js
If missing, run cd server && npm ci && npm run build.
Check logs:
# Docker
docker compose logs -f
# Manual install
tail -f logs/wled_controller.log
Cannot access the dashboard from another machine
- Verify the server is reachable:
curl http://SERVER_IP:8080/health - Check your firewall allows inbound traffic on port 8080.
- Add your server's LAN IP to
cors_origins(see Configure CORS above).
Home Assistant integration not appearing
- Verify HACS installed the component: check that
config/custom_components/wled_screen_controller/exists. - Clear your browser cache.
- Restart Home Assistant.
- Check logs at Settings > System > Logs and search for
wled_screen_controller.
WLED device not responding
- Confirm the device is powered on and connected to Wi-Fi.
- Test it directly:
curl http://DEVICE_IP/json/info - Check that the server and the device are on the same subnet.
- Try restarting the WLED device.
Low FPS or high latency
- Lower the target FPS in the stream settings.
- Reduce
border_widthto decrease the number of sampled pixels. - Check CPU usage on the server (
htopor Task Manager). - On Windows, install the
perfextra for GPU-accelerated capture:pip install ".[perf]"