A Python web application for controlling WLED lights with a modern, responsive web interface. This project provides a wrapper around the WLED JSON API with a beautiful web UI for easy control of your WLED devices.
- Power Control: Turn lights on/off with a single click
- Brightness Control: Adjust brightness with a smooth slider (0-255)
- Color Control:
- Color picker for intuitive color selection
- RGBW input fields for precise control
- Preset color buttons for quick access
- Effects Control:
- Dynamic loading of available WLED effects
- Effect speed and intensity adjustment
- Real-time effect application
- Real-time Updates: UI automatically syncs with WLED device state
- Responsive Design: Works on desktop and mobile devices
- Connection Status: Visual indicator of WLED device connectivity
- Python 3.8 or higher
- A WLED device accessible on your network
- Network connectivity to your WLED device
-
Clone the repository:
git clone <repository-url> cd wled
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install dependencies:
pip install -r requirements.txt
Create a .env file in the project root to configure the application:
# WLED device host (default: http://wled.local)
WLED_HOST=http://wled.local
# Web server configuration (optional)
HOST=127.0.0.1
PORT=8000
RELOAD=false-
Using mDNS (recommended):
- If your WLED device is named "wled", it should be accessible at
http://wled.local - If your device has a different name, use
http://<device-name>.local
- If your WLED device is named "wled", it should be accessible at
-
Using IP Address:
- Find your WLED device's IP address in your router's admin panel
- Use the IP address:
http://192.168.1.100(replace with actual IP)
-
Using WLED App:
- Open the WLED app and check the device's IP address
- Use that IP address in the configuration
-
Run the main application:
python main.py
-
Access the web interface: Open your browser and navigate to
http://127.0.0.1:8000
-
Power Control:
- Click the main power button to toggle lights on/off
- Use the "Turn On" and "Turn Off" buttons for direct control
-
Brightness Control:
- Drag the brightness slider to adjust brightness (0-255)
- The current value is displayed next to the slider
-
Color Control:
- Use the color picker for visual color selection
- Enter precise RGBW values in the input fields
- Click preset color buttons for quick access to common colors
- Click "Set Color" to apply the selected color
-
Effects Control:
- Select an effect from the dropdown menu
- Adjust speed and intensity using the sliders
- Click "Apply Effect" to apply all effect settings at once
The application also provides a REST API for programmatic control:
import requests
# Get current state
response = requests.get('http://127.0.0.1:8000/api/state')
state = response.json()
# Turn lights on
requests.post('http://127.0.0.1:8000/api/power/on')
# Set color (red)
requests.post('http://127.0.0.1:8000/api/color',
json={'red': 255, 'green': 0, 'blue': 0})
# Set brightness
requests.post('http://127.0.0.1:8000/api/brightness',
json={'brightness': 128})
# Apply effect
requests.post('http://127.0.0.1:8000/api/effect',
json={'effect_id': 5})| Method | Endpoint | Description |
|---|---|---|
| GET | /api/state |
Get current WLED state |
| GET | /api/effects |
Get available effects |
| GET | /api/health |
Health check |
| POST | /api/power |
Toggle power |
| POST | /api/power/on |
Turn lights on |
| POST | /api/power/off |
Turn lights off |
| POST | /api/brightness |
Set brightness |
| POST | /api/color |
Set color |
| POST | /api/effect |
Set effect |
| POST | /api/effect/speed |
Set effect speed |
| POST | /api/effect/intensity |
Set effect intensity |
wled/
├── src/
│ ├── __init__.py
│ ├── wled_client.py # WLED API client
│ └── app.py # FastAPI application
├── static/
│ └── app.js # Frontend JavaScript
├── templates/
│ └── index.html # Main web interface
├── tests/
│ ├── __init__.py
│ └── test_wled_client.py
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── .env # Environment configuration
└── README.md # This file
# Run all tests
pytest
# Run tests with coverage
pytest --cov=src
# Run specific test file
pytest tests/test_wled_client.pyThe project follows PEP 8 guidelines. Use the following tools for code quality:
# Format code with Black
black src/ tests/
# Check code style with flake8
flake8 src/ tests/
# Run type checking with mypy
mypy src/-
"WLED not reachable" error:
- Check that your WLED device is powered on and connected to the network
- Verify the WLED_HOST setting in your
.envfile - Try using the IP address instead of the hostname
- Check your firewall settings
-
"Connection failed" error:
- Ensure your computer and WLED device are on the same network
- Try pinging the WLED device to verify connectivity
- Check if the WLED device is accessible via its web interface
-
Effects not loading:
- Some WLED devices may not support the effects API
- Check your WLED firmware version
- Try accessing the effects directly via the WLED web interface
-
Color not updating:
- Ensure the lights are turned on
- Check that the WLED device supports the color format being sent
- Verify the RGBW values are within the valid range (0-255)
Enable debug logging by setting the log level:
# In src/app.py, change:
logging.basicConfig(level=logging.DEBUG)Test connectivity to your WLED device:
# Test mDNS resolution
ping wled.local
# Test direct IP access (replace with your device's IP)
ping 192.168.1.100
# Test HTTP access
curl http://wled.local/json/state- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Run the test suite:
pytest - Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- WLED Project - The amazing WLED firmware
- FastAPI - Modern web framework for building APIs
- Tailwind CSS - Utility-first CSS framework
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Search existing issues on GitHub
- Create a new issue with detailed information about your problem
For WLED-specific issues, refer to the WLED documentation.