A simple web-based control interface for smart light bulbs using Flask and TinyTuya.
LightWebUI provides a sleek, responsive web interface to control Tuya-compatible smart bulbs over your local network. The interface features real-time status updates, smooth animations, and intuitive controls for power, brightness, and color temperature.
Before using this application:
- Ensure your computer and smart bulb are on the same Wi-Fi network.
- Find your bulb’s current IP address by running:
python find_bulb.py
- Update the
BULB_CONFIGblock inapp.pywith your actual:device_idip_address(from step 2)local_keyversion(typically"3.3")
Important: The bulb is initialized once at startup only, exactly as shown in
app.py. Do not re-initialize the bulb inside route handlers or on every request—this will break the persistent connection and cause timeouts.
-
Clone the repository:
git clone https://github.com/S1MS4/LightWebUI.git cd LightWebUI -
Install Python dependencies:
pip install -r requirements.txt
-
Configure your bulb settings in
app.pyas described above.
-
Start the Flask server:
python app.py
-
Open your browser and navigate to:
http://localhost:5000 -
The interface will automatically attempt to connect to your smart bulb. Use the controls to:
- Toggle power on/off
- Adjust brightness using the slider
- Change color temperature
- Apply quick presets
- Flask 2.3.3
- Flask-CORS 4.0.0
- TinyTuya 1.11.1
- Font Awesome 6.4.0 (loaded via CDN)
GET /– Main web interfaceGET /status– Connection status checkGET /get-state– Retrieve current bulb statePOST /power– Toggle power on/offPOST /brightness– Set brightness levelPOST /temperature– Set color temperatureGET /connection– Connection informationPOST /restart– Manual reconnectionGET /debug– Debug information
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
This project is open source and available under the MIT license for personal and educational use.
- Connection Issues: Ensure your bulb is powered on and connected to the same network as your computer.
- No Response: Double-check the IP address (use
find_bulb.py) and verify thelocal_keyinapp.py. - Control Not Working: Confirm your bulb uses Tuya protocol version 3.3.
- Interface Not Loading: Make sure all dependencies are installed and the Flask server is running without errors.
Contributions are welcome. Please ensure your code follows the existing style and includes appropriate comments.