Local control of the Philips Hue Bridge via CLIP API v2: library, CLI, and MCP server
Project description
huehub
Local control of the Philips Hue Bridge via CLIP API v2 — Python library, CLI, and MCP server.
huehub talks directly to your bridge over HTTPS — no Philips cloud, no account, no internet required.
Features
- Full CLIP API v2 coverage — lights, rooms, zones, scenes, sensors, devices
- Async Python library —
async with HueBridgeClient(cfg) as client: ... - Rich CLI — human-readable tables or
--jsonfor scripts - MCP server — expose your bridge as tools to Claude or any MCP client
- TLS cert pinning — extracts and pins the bridge certificate automatically
- SSE event stream — subscribe to real-time bridge events
- On-disk resource cache — fast repeated reads, configurable TTL
Installation
pip install huehub-py
# or with uv
uv add huehub-py
Requires Python 3.14+.
Quick start
1. Discover your bridge
hue discover
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ Host ┃ Bridge ID ┃
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ 192.168.1.10 │ c42996fffec629f5 │
└─────────────────┴──────────────────┘
2. Pin the TLS certificate
hue setup --host 192.168.1.10
Extracting TLS certificate from 192.168.1.10:443…
Certificate saved to ~/.cache/huehub/default/bridge.pem
Press the link button on your Hue Bridge NOW…
Then run: hue authenticate
3. Register an application key
Press the link button on the bridge, then:
hue authenticate
Application key registered: yqPX7XTm…
Config is saved to ~/.config/huehub/config.toml. You're done.
CLI reference
hue [--host IP] [--key KEY] [--json] [--verbose] <command>
| Command | Description |
|---|---|
hue discover |
mDNS / cloud discovery of bridges |
hue setup --host IP |
Extract and pin the bridge TLS certificate |
hue authenticate |
Register a new application key |
hue info |
Bridge firmware, model, API version |
hue lights list |
All lights with status |
hue lights on NAME |
Turn a light on |
hue lights off NAME |
Turn a light off |
hue lights set NAME |
Set brightness / colour / colour-temp |
hue rooms list |
Rooms with light count |
hue rooms on NAME |
Turn all lights in a room on |
hue rooms off NAME |
Turn all lights in a room off |
hue rooms set NAME |
Set brightness / colour for a room |
hue zones list |
Zones with light count |
hue scenes list |
Scenes, optionally filtered by room |
hue scenes activate NAME |
Activate a scene |
hue devices list |
All paired devices |
hue sensors list |
Motion, temperature, light-level, contact |
hue api get PATH |
Raw GET request to /clip/v2/... |
Use --json before the subcommand for machine-readable output:
hue --json rooms list | jq '.[].name'
Python library
import asyncio
from huehub import HueBridgeClient, load_config
async def main():
async with HueBridgeClient(load_config()) as hue:
# List all lights
for light in await hue.list_lights():
print(light.name, light.on, f"{light.brightness:.0%}")
# Turn on a room at 60 % warm white
await hue.turn_on_room("Wohnzimmer", brightness=60, color="2700K")
# Activate a scene
await hue.activate_scene("Relax")
# Stream real-time events
async for event in hue.listen():
print(event)
asyncio.run(main())
Colour input formats
turn_on, set_light, set_room, and set_zone all accept the same flexible color argument:
| Format | Example |
|---|---|
| Colour temperature (Kelvin) | "2700K", "4000k" |
| Named white | "warm", "cool", "daylight" |
| CSS hex | "#FF8800" |
| CSS name | "red", "blue", "coral" |
MCP server
huehub ships with an MCP server that exposes the bridge as tools for Claude or any MCP-compatible client.
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"hue": {
"command": "hue-mcp"
}
}
}
VS Code (agent mode)
{
"mcp": {
"servers": {
"hue": { "command": "hue-mcp", "type": "stdio" }
}
}
}
Available MCP tools
hue_get_bridge_info · hue_list_lights · hue_turn_on · hue_turn_off · hue_set_light · hue_list_rooms · hue_set_room · hue_list_zones · hue_set_zone · hue_list_scenes · hue_activate_scene · hue_list_devices · hue_list_sensors · hue_list_entertainment_zones · hue_get_raw
Configuration
Config file: ~/.config/huehub/config.toml
[bridge]
host = "192.168.1.10"
application_key = "your-key-here"
[tls]
# auto (default) | verify | skip
mode = "verify"
[connection]
request_timeout_s = 10
[cache]
ttl_seconds = 300
[color]
default_transition_ms = 400
Environment variable overrides:
| Variable | Overrides |
|---|---|
HUE_BRIDGE_HOST |
bridge.host |
HUE_APPLICATION_KEY |
bridge.application_key |
HUE_TLS_MODE |
tls.mode |
HUE_CONFIG_DIR |
config directory path |
TLS modes
| Mode | Behaviour |
|---|---|
auto |
Use pinned cert if present, fall back to skip (with warning) |
verify |
Require pinned cert — fail if absent |
skip |
Disable TLS verification (not recommended) |
Run hue setup to extract and pin the bridge certificate. The certificate is stored in ~/.cache/huehub/<bridge-id>/bridge.pem. Connection by IP is supported even though the bridge certificate's SAN contains the hostname.
Development
git clone https://github.com/jenreh/huehub-py
cd huehub-py
uv sync --extra dev
task test # pytest with coverage
task lint # ruff + mypy
task format # ruff format
[!NOTE] A
FakeBridgesimulator (huehub.simulator) is included for use in tests. It registers all expected CLIP v2 endpoints againstpytest-httpxwithout requiring a real bridge.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huehub_py-0.1.0.tar.gz.
File metadata
- Download URL: huehub_py-0.1.0.tar.gz
- Upload date:
- Size: 41.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df17567027d685ac1ad96eb35d0bff3420b2c15a6871dc1f08044395ac83d9ac
|
|
| MD5 |
2f97daafec45e0cc91a8d65db01ed497
|
|
| BLAKE2b-256 |
cf49812bcf22ee6d37677a4808d763ec7b77153a631603897af67e564e15f426
|
File details
Details for the file huehub_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: huehub_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc666ae42c7484f14c416312548756c9c829067f5b2c360a8924555542969042
|
|
| MD5 |
5e6d573981d44ea985f666597009f029
|
|
| BLAKE2b-256 |
7cac7d50670668884b6cbbb312795fcbebd27d96211d0dcf3575d5bb80b19b80
|