This is a complete WLED ambient lighting controller that captures screen border pixels and sends them to WLED devices for immersive ambient lighting effects. ## Server Features: - FastAPI-based REST API with 17+ endpoints - Real-time screen capture with multi-monitor support - Advanced LED calibration system with visual GUI - API key authentication with labeled tokens - Per-device brightness control (0-100%) - Configurable FPS (1-60), border width, and color correction - Persistent device storage (JSON-based) - Comprehensive Web UI with dark/light themes - Docker support with docker-compose - Windows monitor name detection via WMI (shows "LG ULTRAWIDE" etc.) ## Web UI Features: - Device management (add, configure, remove WLED devices) - Real-time status monitoring with FPS metrics - Settings modal for device configuration - Visual calibration GUI with edge testing - Brightness slider per device - Display selection with friendly monitor names - Token-based authentication with login/logout - Responsive button layout ## Calibration System: - Support for any LED strip layout (clockwise/counterclockwise) - 4 starting position options (corners) - Per-edge LED count configuration - Visual preview with starting position indicator - Test buttons to light up individual edges - Smart LED ordering based on start position and direction ## Home Assistant Integration: - Custom HACS integration - Switch entities for processing control - Sensor entities for status and FPS - Select entities for display selection - Config flow for easy setup - Auto-discovery of devices from server ## Technical Stack: - Python 3.11+ - FastAPI + uvicorn - mss (screen capture) - httpx (async WLED client) - Pydantic (validation) - WMI (Windows monitor detection) - Structlog (logging) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
5.2 KiB
WLED Screen Controller - Home Assistant Integration
Native Home Assistant integration for WLED Screen Controller with full HACS support.
Overview
This integration connects Home Assistant to the WLED Screen Controller server, providing:
- 🎛️ Switch Entities - Turn processing on/off per device
- 📊 Sensor Entities - Monitor FPS, status, and frame count
- 🖥️ Select Entities - Choose which display to capture
- 🔄 Auto-Discovery - Devices appear automatically
- 📦 HACS Compatible - Install directly from HACS
- ⚙️ Config Flow - Easy setup through UI
Installation
Method 1: HACS (Recommended)
-
Install HACS if you haven't already:
-
Add Custom Repository:
- Open HACS in Home Assistant
- Click the menu (⋮) → Custom repositories
- Add URL:
https://github.com/yourusername/wled-screen-controller - Category: Integration
- Click Add
-
Install Integration:
- In HACS, search for "WLED Screen Controller"
- Click Download
- Restart Home Assistant
-
Configure:
- Go to Settings → Devices & Services
- Click + Add Integration
- Search for "WLED Screen Controller"
- Enter your server URL (e.g.,
http://192.168.1.100:8080) - Click Submit
Method 2: Manual Installation
-
Download:
cd /config # Your Home Assistant config directory mkdir -p custom_components -
Copy Files: Copy the entire
custom_components/wled_screen_controllerfolder to your Home Assistantcustom_components/directory. -
Restart Home Assistant
-
Configure:
- Settings → Devices & Services → Add Integration
- Search for "WLED Screen Controller"
Configuration
Initial Setup
When adding the integration, you'll be prompted for:
- Name: Friendly name for the integration (default: "WLED Screen Controller")
- Server URL: URL of your WLED Screen Controller server (e.g.,
http://192.168.1.100:8080)
The integration will automatically:
- Verify connection to the server
- Discover all configured WLED devices
- Create entities for each device
Entities Created
For each WLED device, the following entities are created:
Switch Entities
switch.{device_name}_processing
- Controls processing on/off for the device
- Attributes:
device_id: Internal device IDfps_target: Target FPSfps_actual: Current FPSdisplay_index: Active displayframes_processed: Total frameserrors_count: Error countuptime_seconds: Processing uptime
Sensor Entities
sensor.{device_name}_fps
- Current FPS value
- Unit: FPS
- Attributes:
target_fps: Target FPS setting
sensor.{device_name}_status
- Processing status
- States:
processing,idle,unavailable,unknown
sensor.{device_name}_frames_processed
- Total frames processed counter
- Continuously increasing while processing
Select Entities
select.{device_name}_display
- Select which display to capture
- Options:
Display 0,Display 1, etc. - Changes take effect immediately
Usage Examples
Basic Automation
Turn on processing when TV turns on:
automation:
- alias: "Auto Start WLED with TV"
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: "on"
action:
- service: switch.turn_on
target:
entity_id: switch.living_room_wled_processing
- alias: "Auto Stop WLED with TV"
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: "off"
action:
- service: switch.turn_off
target:
entity_id: switch.living_room_wled_processing
Lovelace UI Examples
Simple Card
type: entities
title: WLED Screen Controller
entities:
- entity: switch.living_room_wled_processing
- entity: sensor.living_room_wled_fps
- entity: sensor.living_room_wled_status
- entity: select.living_room_wled_display
Advanced Card
type: vertical-stack
cards:
- type: entity
entity: switch.living_room_wled_processing
name: Ambient Lighting
icon: mdi:television-ambient-light
- type: conditional
conditions:
- entity: switch.living_room_wled_processing
state: "on"
card:
type: entities
entities:
- entity: sensor.living_room_wled_fps
name: Current FPS
- entity: sensor.living_room_wled_frames_processed
name: Frames Processed
- entity: select.living_room_wled_display
name: Display Selection
Troubleshooting
Integration Not Appearing
- Check HACS installation
- Clear browser cache
- Restart Home Assistant
- Check logs: Settings → System → Logs
Connection Errors
-
Verify server is running:
curl http://YOUR_SERVER_IP:8080/health -
Check firewall settings
-
Ensure Home Assistant can reach server
-
Try http:// not https://
Entities Not Updating
- Check coordinator logs
- Verify server has devices
- Restart integration
Support
License
MIT License - see ../../LICENSE