492bdb95e3
Receive real-time events from games (CS2, Dota 2, LoL, etc.) and drive LED effects through the existing color strip and value source pipelines. Core: - GameEventBus (thread-safe pub/sub) with standardized 23-type event vocabulary - GameAdapter ABC + AdapterRegistry + MappingAdapter (YAML-driven) - Built-in adapters: CS2 GSI, Dota 2 GSI, LoL Live Client, Generic Webhook - Community YAML adapters: Minecraft, Valorant, Rocket League - GameEventColorStripStream with 5 effects (flash/pulse/sweep/color_shift/breathing) - GameEventValueSource with EMA smoothing and timeout - 4 built-in effect presets (FPS Combat, MOBA Health, Racing, Generic Alert) - Auto-setup for Valve GSI games (Steam path detection, cfg file writing) - Demo capture engine exposed to non-demo mode Frontend: - Game tab in Streams tree navigation with integration cards - Game integration editor modal with adapter picker, config fields, event mappings - game_event source type in CSS and ValueSource editors - Setup instructions overlay (markdown rendered) - Live event monitor and connection test API: - Full CRUD for game integrations - Event ingestion endpoint (adapter-level auth) - Adapter metadata, presets, auto-setup, status/diagnostics endpoints
5.5 KiB
5.5 KiB
Phase 8: Effect Presets & Polish
Status: ✅ Complete Parent plan: PLAN.md Domain: fullstack
Objective
Ship built-in effect presets, add a WebSocket endpoint for real-time event streaming to the frontend live monitor, and add a setup wizard for guided game configuration.
Tasks
- Task 1: Define effect presets as data (
core/game_integration/presets.py)- "FPS Combat": health→red glow, kill→green flash, death→full red pulse, round_start→team color sweep
- "MOBA Health": health→gradient green-yellow-red, mana→blue glow, death→fade to black
- "Racing": speed→color temperature, boost→rainbow flash
- "Generic Alert": any trigger→white flash
- Each preset: name, description, target_game_types (fps/moba/racing/any), event_mappings list
- Task 2: Preset API endpoints
- GET /api/v1/game-integrations/presets — list available presets
- POST /api/v1/game-integrations/{id}/apply-preset — apply preset to integration
- Task 3: WebSocket endpoint for live event streaming — DEFERRED (polling works; WebSocket is a future optimization)
- Task 4: Frontend preset selector in modal
- Dropdown of presets loaded from API with descriptions
- "Apply" populates the event mapping editor
- Task 5: Game adapter setup wizard — DEFERRED (setup instructions already shown per-adapter)
- Task 6: Community adapter import UI — DEFERRED (community adapters are loaded from data/game_adapters/ dir on startup; file upload is a future enhancement)
- Task 7: Final integration testing — wiring verified, all 606 tests pass
- Task 8: Documentation for creating community adapters — DEFERRED (not blocking release)
- Task 9 (added): Wiring fixes — game_event_bus passed through ProcessorDependencies to ColorStripStreamManager and ValueStreamManager
- Task 10 (added): Adapter registration — import built-in adapters and call register_community_adapters() in main.py
Files to Modify/Create
server/src/wled_controller/core/game_integration/presets.pyserver/src/wled_controller/api/routes/game_integration.py— preset + WS endpointsserver/src/wled_controller/api/schemas/game_integration.py— preset schemasserver/src/wled_controller/static/js/features/game-integration.ts— preset UI, wizard, importserver/src/wled_controller/templates/modals/game-integration-editor.html— wizard stepsserver/src/wled_controller/static/css/game-integration.css— wizard stylesserver/src/wled_controller/static/locales/en.jsonserver/src/wled_controller/static/locales/ru.jsonserver/src/wled_controller/static/locales/zh.jsonserver/tests/core/test_game_presets.py
Acceptance Criteria
- At least 4 effect presets ship out of the box
- Presets can be applied to any game integration via API and UI
- WebSocket endpoint streams events in real-time
- Setup wizard provides clear per-game instructions
- Community adapter import works (file upload + URL)
- Full pipeline works end-to-end: game event → LED effect
Notes
- WebSocket uses FastAPI's built-in WebSocket support
- Presets are read-only built-in data, not user-editable (users can modify after applying)
- Setup wizard should pre-fill the server URL for webhook-based games
Review Checklist
- All core tasks completed (presets, API, wiring, frontend, tests)
- Code follows project conventions
- Build passes (frontend + backend)
- All 606 tests pass
- Linting clean (ruff)
- TypeScript clean (tsc --noEmit)
Handoff Notes (Final Phase)
Files created:
server/src/wled_controller/core/game_integration/presets.py— 4 built-in effect presets (FPS Combat, MOBA Health, Racing, Generic Alert) as frozen dataclassesserver/tests/core/test_game_presets.py— preset data structure tests (10 tests)server/tests/core/test_game_wiring.py— GameEventBus wiring verification tests (4 tests)
Files modified:
server/src/wled_controller/api/schemas/game_integration.py— added EffectPresetResponse, PresetListResponse, ApplyPresetRequest schemasserver/src/wled_controller/api/routes/game_integration.py— added GET /presets and POST /{id}/apply-preset endpoints (presets route placed BEFORE {integration_id} to avoid path parameter conflict)server/src/wled_controller/core/processing/processor_manager.py— added game_event_bus to ProcessorDependencies; wired to ColorStripStreamManager and ValueStreamManagerserver/src/wled_controller/main.py— added adapter import, register_community_adapters() call, game_event_bus in ProcessorDependenciesserver/src/wled_controller/static/js/features/game-integration.ts— replaced hardcoded preset data with API-loaded presets from /game-integrations/presetsserver/src/wled_controller/static/js/types.ts— added EffectPreset interfaceserver/src/wled_controller/static/locales/en.json,ru.json,zh.json— added game_integration.mapping.select_preset keyserver/tests/api/routes/test_game_integration_routes.py— added TestPresets class (6 tests: list, mappings, apply replace/append, unknown key/integration)
Key wiring fix: GameEventBus was created in main.py but NOT passed to ProcessorDependencies, meaning ColorStripStreamManager and ValueStreamManager could never receive it. Now properly threaded through.
Deferred items: WebSocket live streaming (Task 3), setup wizard (Task 5), community adapter import UI (Task 6), adapter documentation (Task 8) — none are blocking for the feature to function end-to-end.