Skip to content

mgara/hue-ambient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philips Hue Ambient Lighting for Mac

A Python-based Mac application that creates dynamic ambient lighting by syncing your Philips Hue lights with colors detected from your camera input. Perfect for creating an immersive viewing experience when watching TV or movies.

Features

  • Real-time Color Detection: Analyzes video input from your Mac's camera
  • Multiple Detection Methods:
    • Center Area: Focuses on the center of the frame
    • Full Screen: Averages colors across the entire frame
    • Grid Average: Divides frame into grid and averages colors
    • Dominant Color: Uses k-means clustering to find the most prominent color
  • Color Smoothing: Reduces flickering with temporal smoothing
  • Adjustable Settings:
    • Brightness control (0-254)
    • Saturation control (0-254)
    • Update rate (1-30 fps)
    • Camera selection
  • User-Friendly GUI: Built with PyQt5 for easy control

Requirements

  • macOS
  • Python 3.8 or higher
  • Philips Hue Bridge and compatible lights
  • Camera (built-in or external)

Installation

  1. Clone or download this repository:
cd /Users/meher.gara/work/hue-ambient
  1. Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt

Setup

Finding Your Hue Bridge IP Address

You need to find your Hue Bridge's IP address. There are several ways to do this:

Method 1: Philips Hue App

  1. Open the Philips Hue app on your phone
  2. Go to Settings > Hue Bridges > (i) icon
  3. Note the IP address shown

Method 2: Router Admin Panel

  1. Log into your router's admin panel
  2. Look for connected devices
  3. Find the device named "Philips Hue"

Method 3: Discovery URL Visit: https://discovery.meethue.com/ This will show all Hue bridges on your network.

First-Time Bridge Connection

When connecting to your Hue Bridge for the first time:

  1. Enter your Bridge IP address in the app
  2. Click "Connect to Bridge"
  3. Press the physical button on top of your Hue Bridge
  4. Wait for the connection to complete

The app will save the connection credentials for future use.

Usage

  1. Start the application:
python3 main.py
  1. Configure the Hue Bridge:

    • Enter your Bridge IP address
    • Click "Connect to Bridge"
    • Press the button on your Hue Bridge if prompted
  2. Configure Camera:

    • Select your camera from the dropdown
    • The default is usually Camera 0 (built-in camera)
  3. Adjust Settings:

    • Choose a detection method
    • Set your preferred update rate (higher = more responsive, more CPU usage)
    • Adjust brightness and saturation to your liking
    • Enable/disable color smoothing
  4. Start Ambient Lighting:

    • Click "Start Ambient Lighting"
    • Your Hue lights will now sync with the colors detected by your camera
  5. Stop when done:

    • Click "Stop Ambient Lighting"

Tips for Best Results

  1. Camera Positioning: Point your camera at your TV screen for best results

    • Position the camera to capture the TV without reflections
    • Adjust distance to minimize dark borders in the frame
  2. Detection Method:

    • Use "Center Area" for focused content (ideal for TVs)
    • Use "Dominant Color" for more accurate color representation
    • Use "Grid Average" for balanced ambient lighting
  3. Update Rate:

    • 10-15 fps provides good balance between responsiveness and CPU usage
    • Lower rates (5-10 fps) for subtle ambient effects
    • Higher rates (20-30 fps) for fast-paced content
  4. Smoothing:

    • Keep enabled to reduce flickering during scene changes
    • Disable for more immediate color changes
  5. Brightness & Saturation:

    • Lower brightness for subtle ambient effects
    • Increase saturation for more vibrant colors
    • Adjust based on room lighting conditions

Project Structure

hue-ambient/
├── main.py                 # Application entry point
├── requirements.txt        # Python dependencies
├── README.md              # This file
├── camera/
│   ├── __init__.py
│   └── capture.py         # Camera capture functionality
├── color/
│   ├── __init__.py
│   └── analyzer.py        # Color detection and analysis
├── gui/
│   ├── __init__.py
│   └── main_window.py     # Main application window
└── hue/
    ├── __init__.py
    └── controller.py      # Philips Hue bridge controller

Troubleshooting

Camera Issues

  • Camera not working: Check camera permissions in System Preferences > Security & Privacy > Camera
  • No video feed: Try selecting a different camera index in the dropdown
  • Poor quality: Ensure adequate lighting in the room

Hue Bridge Issues

  • Can't connect: Verify Bridge IP address is correct
  • Connection timeout: Ensure your Mac and Bridge are on the same network
  • Lights not responding: Check that lights are on and reachable in the Hue app

Performance Issues

  • High CPU usage: Lower the update rate
  • Laggy response: Reduce camera resolution or use a simpler detection method
  • Flickering lights: Enable color smoothing

Advanced Configuration

You can modify the following parameters in the code:

  • color/analyzer.py: Adjust color detection algorithms
  • hue/controller.py: Modify XY color space conversion
  • camera/capture.py: Change camera resolution and FPS

Known Limitations

  • Requires camera to be pointed at the screen (screen capture would be more accurate but requires additional permissions)
  • Color accuracy depends on camera quality and lighting conditions
  • Network latency may affect responsiveness with wireless Hue bulbs

Future Enhancements

Potential features to add:

  • Screen capture mode (instead of camera)
  • Multi-zone lighting for entertainment areas
  • Scene presets and profiles
  • Scheduling and automation
  • Music visualization mode
  • Integration with other smart home platforms

License

This project is for personal use. Philips Hue is a trademark of Signify Holding.

Credits

Built with:

  • OpenCV for computer vision
  • PyQt5 for GUI
  • phue for Philips Hue integration
  • NumPy for numerical operations

Support

For issues or questions:

  1. Check the Troubleshooting section above
  2. Verify your Hue Bridge and lights are working with the official Hue app
  3. Ensure all dependencies are properly installed

Enjoy your ambient lighting experience!

About

Hue sync app to tv with camera

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors