A Python application that integrates your Govee table lamp with Lichess chess games. The lamp changes color based on whose turn it is during gameplay.
- 🎮 Monitors active Lichess games in real-time
- 💡 Automatically changes lamp color based on whose turn it is
- 🎨 Themes - Pre-configured color schemes (classic, royal, ocean, amber, and more)
- 🌅 Gradual Dimming - Smooth brightness transitions when colors change
- 🔄 Hot Reload - Change themes and settings mid-game without restarting
- 🟢 Green light when it's your turn (or theme-based colors)
- 🔴 Red light when it's your opponent's turn (or theme-based colors)
- ⏰ Time pressure warnings - lamp blinks when time is low (≤30s warning, ≤10s critical)
⚠️ Check detection - lamp blinks yellow when you're in check- 💡 Move notifications - brief flash when any move is made
- 🎉 Game result celebration - green pulse for wins, red/yellow for loss/draw
- 🔄 Automatic state restoration after games end
- 🔌 Enable/Disable API - Control the lamp remotely via REST API
- Python 3.7 or higher
- A Lichess account
- A Govee table lamp connected to your network (WiFi)
- API credentials for both services
- Network Requirements: The machine running this service needs:
- Internet access (to reach Lichess API)
- Access to the same network as your Govee lamp (typically same WiFi network)
pip install -r requirements.txt- Go to Lichess API Tokens
- Create a new token with appropriate permissions
- Copy the token
You'll need:
- Govee API Key: Get this from the Govee developer portal or app
- Device MAC Address: Find this in your Govee Home app under device settings
Note: This project uses govee-api-laggat, a community library for controlling Govee devices. You can also try other libraries like govee-api or aiogovee if needed.
Copy the example config file and fill in your credentials:
cp config.json.example config.jsonEdit config.json with your credentials:
{
"lichess_token": "your_lichess_api_token_here",
"govee_api_key": "your_govee_api_key_here",
"govee_device_mac": "your_device_mac_address_here",
"govee_device_ip": "optional_ip_address_for_lan_control",
"restore_color": "#FFC864",
"restore_brightness": 100,
"theme": "classic",
"gradual_dim_enabled": true,
"gradual_dim_duration": 1.5
}See config.json.example for all available options.
Configuration Options:
lichess_token(required): Your Lichess API tokengovee_api_key(required): Your Govee API keygovee_device_mac(required): MAC address of your Govee devicegovee_device_ip(optional): IP address for faster LAN controlrestore_color(optional): Hex color code to restore after games (e.g.,"#FFC864"for warm yellow)restore_brightness(optional): Brightness level (0-100) to restore after games (default: 100)theme(optional): Theme name (e.g., "classic", "royal", "ocean", "amber", "traffic")gradual_dim_enabled(optional): Enable gradual dimming when colors change (default: true)gradual_dim_duration(optional): Duration of gradual dim in seconds (default: 1.5)time_pressure_enabled(optional): Enable time pressure warnings (default: true)time_pressure_warning(optional): Seconds remaining to trigger warning blink (default: 30)time_pressure_critical(optional): Seconds remaining to trigger critical fast blink (default: 10)check_enabled(optional): Enable check detection (default: true)check_color(optional): Hex color code for check indication (default: "#FFFF00" yellow)check_brightness(optional): Brightness level when in check (default: 60)check_blink(optional): Blink lamp when in check (default: true)move_notification_enabled(optional): Enable move notifications (default: true)move_notification_color(optional): Hex color code for move flash (default: "#FFFFFF" white)move_notification_brightness(optional): Brightness level for move flash (default: 80)move_notification_duration(optional): Duration of move flash in seconds (default: 0.15)celebration_enabled(optional): Enable game result celebration (default: true)celebration_win_color(optional): Hex color for win celebration (default: "#00FF00" green)celebration_loss_color(optional): Hex color for loss indication (default: "#FF0000" red)celebration_draw_color(optional): Hex color for draw indication (default: "#FFFF00" yellow)celebration_brightness(optional): Brightness for celebration (default: 100)celebration_pattern_count(optional): Number of pulses/flashes for celebration (default: 3)
Note: You can override theme colors by setting my_turn_color, opponent_turn_color, my_turn_brightness, and opponent_turn_brightness individually.
Finding Hex Color Values:
- Use an online color picker like htmlcolorcodes.com/color-picker
- Pick the color you want your lamp to return to after games
- Copy the hex code (e.g.,
#FFC864) and add it torestore_colorin config.json
Alternatively, you can set environment variables:
export LICHESS_TOKEN="your_token"
export GOVEE_API_KEY="your_key"
export GOVEE_DEVICE_MAC="your_mac"Run the application directly:
python chess_lamp.pyThe application will:
- Monitor for active Lichess games
- When a game is detected, start streaming game events
- Update the lamp color based on whose turn it is
The application can run on any machine on your network - it doesn't need to be on the same computer where you're playing Lichess. It only needs:
- Internet access to reach the Lichess API
- Network access to your Govee lamp (same WiFi network)
Use the provided script to run as a background service:
# Make the script executable
chmod +x run_service.sh
# Start the service
./run_service.sh start
# Check status
./run_service.sh status
# Stop the service
./run_service.sh stop
# View logs
tail -f lichess_govee.logFor a more robust system service on Linux:
-
Edit
lichess-govee.serviceand update:YOUR_USERNAMEwith your actual username- Paths if needed
-
Install the service:
sudo cp lichess-govee.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable lichess-govee.service sudo systemctl start lichess-govee.service -
Manage the service:
sudo systemctl status lichess-govee.service sudo systemctl stop lichess-govee.service sudo systemctl restart lichess-govee.service sudo journalctl -u lichess-govee.service -f # View logs
Deploy using Docker Compose for easy setup and management:
# 1. Create config.json from example
cp config.json.example config.json
# 2. Edit config.json with your API credentials
nano config.json
# 3. Start the container
docker compose up -d
# 4. View logs
docker compose logs -f
# 5. Stop the container
docker compose down
# 6. Restart the container
docker compose restartNote: The container uses network_mode: host to access your Govee lamp on the local network.
The lamp uses themes to provide chess-themed color schemes. You can change themes in config.json or use the API.
Available Themes:
classic- Warm white & midnight blue (recommended)royal- Royal gold & deep purpleocean- Sky blue & navy blueamber- Amber/gold & tealtraffic- Classic red/green (original behavior)pure- Pure white & dark grayivory- Ivory & charcoal- And more! See configuration examples below
Default (traffic theme):
- 🟢 Green: Your turn at 40% brightness
- 🔴 Red: Opponent's turn at 40% brightness
- ⏰ Time Pressure: Lamp blinks when time is low:
- Warning (≤30s): Single blink when it's your turn
- Critical (≤10s): Fast double blink when it's your turn
⚠️ Check Detection: Lamp indicates when you're in check:- Yellow blink (default): Fast triple blink when in check
- Configurable color and brightness
- 💡 Move Notifications: Brief white flash when any move is made
- Quick visual feedback for move detection
- Configurable color, brightness, and duration
- 🎉 Game Result Celebration: Visual celebration when games end
- Win: Green pulsing pattern (3 pulses)
- Loss: Red flash pattern
- Draw: Yellow flash pattern
- Configurable colors and pattern count
- Restore Color: Returns to your configured
restore_colorwhen game ends
State Restoration:
- Before each game, the lamp's current state is saved
- After the game ends, the lamp restores to its previous state
- If the previous state can't be determined, it uses the
restore_colorfrom config.json - You can configure
restore_coloras a hex code (e.g.,"#FFC864") to match your preferred lamp color
Hot Reload:
- Edit
config.jsonduring a game to change themes or settings - Changes are automatically detected and applied within ~1 second
- No need to restart the service!
Customization:
You can customize colors in config.json:
- Use a
themefor pre-configured color schemes - Or set
my_turn_color,opponent_turn_color,my_turn_brightness,opponent_turn_brightnessindividually
- The application uses the
berserklibrary to connect to the Lichess API - It monitors for ongoing games using the Lichess Games API
- When a game is detected, it streams game events in real-time using the Board API
- Based on the move count and player colors, it determines whose turn it is
- The Govee lamp color is updated accordingly using the
govee-api-laggatlibrary
- Ensure your Govee lamp is connected to the same network
- Verify the MAC address is correct
- Check that the Govee API key is valid
- Make sure you have an active game on Lichess
- Verify your Lichess API token has the correct permissions
- Check your internet connection
- Verify all API credentials are correct
- Check rate limits for both Lichess and Govee APIs
- Ensure you're using the correct API endpoints
You can customize the restore color, brightness, and time pressure warnings in config.json:
{
"restore_color": "#FFC864",
"restore_brightness": 100,
"time_pressure_enabled": true,
"time_pressure_warning": 30,
"time_pressure_critical": 10
}restore_color: Hex color code (e.g.,"#FFC864"for warm yellow) or RGB dict{"r": 255, "g": 200, "b": 100}restore_brightness: Brightness level 0-100 (default: 100)time_pressure_enabled: Enable/disable time pressure warnings (default: true)time_pressure_warning: Seconds remaining to trigger warning blink (default: 30)time_pressure_critical: Seconds remaining to trigger critical fast blink (default: 10)
You can also customize the behavior by modifying the ChessLamp class:
- Colors: Change RGB values in the color dictionaries
- Brightness: Adjust brightness levels (0-100)
- Polling interval: Modify the sleep time in
monitor_games()
This service can run on any machine on your network - it doesn't need to be on the same computer where you play Lichess.
This project uses GitOps with ArgoCD for automated Kubernetes deployments:
- GitHub Actions builds Docker images and pushes to GHCR
- GitHub Actions updates Kubernetes manifests with new image tags
- ArgoCD automatically syncs changes from Git to Kubernetes cluster
Prerequisites:
- Kubernetes cluster
- ArgoCD installed
- ArgoCD Application configured (see
argocd/application.yaml)
Setup:
# 1. Apply ArgoCD Application
kubectl apply -f argocd/application.yaml
# 2. ArgoCD will automatically:
# - Create namespace
# - Deploy from k8s/chess-lamp-deployment.yaml
# - Monitor Git for changesAccess ArgoCD UI:
- URL:
https://argocd.monkeyjuicey.com(or your ArgoCD URL) - Default username:
admin - Get password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
How it works:
- Push code → GitHub Actions builds image → Updates
k8s/chess-lamp-deployment.yaml→ ArgoCD auto-syncs → Deployment updates
For local testing, you can run directly:
# 1. Install dependencies
pip install -r requirements.txt
# 2. Create config.json
cp config.json.example config.json
nano config.json # Add your API credentials
# 3. Run
python chess_lamp.pyOr use Docker Compose for local testing:
docker compose upThe application includes a REST API server (port 5000) for remote control:
GET /api/status- Get current status (enabled state, colors, current game)GET /api/themes- Get list of available themesPOST /api/theme- Set theme by name:{"theme": "classic"}POST /api/enable- Enable/disable chess-lamp:{"enabled": true}or{"enabled": false}POST /api/dimming- Configure gradual dimming:{"enabled": true, "duration": 1.5}
Example:
# Disable chess-lamp (restores lamp to default color)
curl -X POST http://localhost:5000/api/enable -H "Content-Type: application/json" -d '{"enabled": false}'
# Change theme
curl -X POST http://localhost:5000/api/theme -H "Content-Type: application/json" -d '{"theme": "royal"}'
# Check status
curl http://localhost:5000/api/statusThis project is provided as-is for personal use.
Feel free to submit issues or pull requests if you'd like to improve this integration!