A Python application for real-time screen color synchronization with Home Assistant smart lights.
- Real-time Color Sync: Synchronize screen colors with smart lights in real-time
 - Multiple Color Modes:
average- Average color from entire screendominant- Most dominant color on screencenter- Color from center of screen (fastest)
 - Fast Mode: Quick capture mode for optimal performance
 - Rate Limiting: Control update frequency to avoid API spam
 - Multi-Monitor Support: Support for multiple monitors
 - Home Assistant Integration: Direct integration with Home Assistant
 
- Python 3.7+
 - Home Assistant with RGB-capable smart light
 - Monitor/screen to sync
 
- Clone repository:
 
git clone https://github.com/fadelmvi/screen-light-sync
cd screen-light-sync- Install dependencies:
 
pip install -r requirements.txt- Setup configuration:
Copy the 
.env.examplefile and configure: 
cp .env.example .envThen edit .env with your settings:
HA_URL: Your Home Assistant URLHA_TOKEN: Home Assistant access tokenLIGHT_ENTITY: Your smart light entity ID
Copy the example environment file and configure your settings:
cp .env.example .envEdit the .env file with your Home Assistant configuration:
# Home Assistant Configuration
HA_URL=http://your-home-assistant:8123/api/services/light/turn_on
HA_TOKEN=your-home-assistant-token
LIGHT_ENTITY=light.your_smart_light
# Screen Capture Settings
UPDATE_INTERVAL=0.5
COLOR_CHANGE_THRESHOLD=25
BRIGHTNESS=255- Login to Home Assistant
 - Go to Profile → Long-Lived Access Tokens
 - Click "Create Token"
 - Copy the token and paste it into the 
HA_TOKENfield in your.envfile 
python main.py# Use dominant color mode
python main.py --mode dominant
# Fast mode with center color
python main.py --fast
# Custom update interval
python main.py --interval 1.0
# Use second monitor
python main.py --monitor 2
# Test Home Assistant connection
python main.py --test| Option | Description | Default | 
|---|---|---|
--mode | 
Color extraction mode: average, dominant, center | 
average | 
--interval | 
Update interval in seconds | 0.5 | 
--fast | 
Fast mode - use center capture area | False | 
--test | 
Test Home Assistant connection | False | 
--monitor | 
Monitor index to capture | 1 | 
screen-light-sync/
├── main.py                 # Application entry point
├── requirements.txt        # Dependencies
├── README.md              # Documentation
└── src/
    ├── __init__.py        # Package initialization
    ├── config.py          # Configuration
    ├── color_utils.py     # Color extraction utilities
    ├── ha_controller.py   # Home Assistant controller
    └── screen_capture.py  # Screen capture utilities
# Install development dependencies
pip install -r requirements.txt
# Run tests (if available)
pytest
# Format code
black .
# Lint code
flake8 .- Add new color extraction function in 
src/color_utils.py - Update 
ColorModeenum insrc/screen_capture.py - Update 
extract_colormethod inScreenLightSyncclass 
- Use Fast Mode (
--fast) for best performance - Adjust interval - higher interval = lower CPU usage
 - Use Center Mode for screens with static content on edges
 - Single monitor - disable additional monitors if not needed
 
# Test Home Assistant connection
python main.py --test- Use 
--fastmode - Increase 
--intervalvalue - Check CPU usage and adjust accordingly
 
| Error | Solution | 
|---|---|
Import "numpy" could not be resolved | 
Install: pip install numpy | 
Connection failed | 
Check HA_URL and HA_TOKEN in .env file | 
Entity not found | 
Verify LIGHT_ENTITY ID in Home Assistant | 
MIT License - see LICENSE file for details.
- Fork repository
 - Create feature branch
 - Commit changes
 - Push to branch
 - Create Pull Request
 
If you encounter issues, please:
- Check troubleshooting section
 - Create issue on GitHub
 - Contact developer
 
Happy syncing! 🌈💡