← 返回
开发者工具 中文

Homebridge

Control smart home devices via Homebridge Config UI X REST API. Use to list, turn on/off, adjust brightness, color, or temperature of HomeKit-compatible accessories. Supports lights, switches, thermostats, fans, and other Homebridge-managed devices.
通过 Homebridge Config UI X REST API 控制智能家居设备。用于列出或控制 HomeKit 配件,支持开关、调节亮度、颜色或温度。适用于灯光、开关、恒温器、风扇等 Homebridge 管理的设备。
jiasenl jiasenl 来源
开发者工具 clawhub v0.1.0 1 版本 99877 Key: 无需
★ 1
Stars
📥 2,417
下载
💾 39
安装
1
版本
#latest

概述

Homebridge Control

Control smart home devices through Homebridge Config UI X's REST API.

Prerequisites

  1. Homebridge with Config UI X installed and running
  2. Credentials file at ~/.clawdbot/credentials/homebridge.json:

```json

{

"url": "https://homebridge.local:8581",

"username": "admin",

"password": "your-password"

}

```

API Overview

Homebridge Config UI X exposes a REST API. View full documentation at {HOMEBRIDGE_URL}/swagger.

Authentication

All API calls require a Bearer token. Obtain it first:

# Get auth token
TOKEN=$(curl -s -X POST "${HOMEBRIDGE_URL}/api/auth/login" \
  -H "Content-Type: application/json" \
  -d "{\"username\":\"${HOMEBRIDGE_USERNAME}\",\"password\":\"${HOMEBRIDGE_PASSWORD}\"}" \
  | jq -r '.access_token')

Common Operations

List All Accessories

curl -s "${HOMEBRIDGE_URL}/api/accessories" \
  -H "Authorization: Bearer ${TOKEN}" | jq

Response includes accessory uniqueId, serviceName, type, and current values.

Get Accessory Layout (Rooms)

curl -s "${HOMEBRIDGE_URL}/api/accessories/layout" \
  -H "Authorization: Bearer ${TOKEN}" | jq

Control an Accessory

Use PUT to update accessory characteristics:

# Turn on a light/switch
curl -s -X PUT "${HOMEBRIDGE_URL}/api/accessories/{uniqueId}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"characteristicType": "On", "value": true}'

# Turn off
curl -s -X PUT "${HOMEBRIDGE_URL}/api/accessories/{uniqueId}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"characteristicType": "On", "value": false}'

# Set brightness (0-100)
curl -s -X PUT "${HOMEBRIDGE_URL}/api/accessories/{uniqueId}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"characteristicType": "Brightness", "value": 50}'

# Set color (Hue: 0-360, Saturation: 0-100)
curl -s -X PUT "${HOMEBRIDGE_URL}/api/accessories/{uniqueId}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"characteristicType": "Hue", "value": 240}'

# Set thermostat target temperature
curl -s -X PUT "${HOMEBRIDGE_URL}/api/accessories/{uniqueId}" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"characteristicType": "TargetTemperature", "value": 22}'

Common Characteristic Types

TypeValuesDescription
----------------------------------------------------------------------
Ontrue/falsePower state
Brightness0-100Light brightness %
Hue0-360Color hue in degrees
Saturation0-100Color saturation %
ColorTemperature140-500Color temp in Mired
TargetTemperature10-38Thermostat target °C
TargetHeatingCoolingState0-30=Off, 1=Heat, 2=Cool, 3=Auto
RotationSpeed0-100Fan speed %
Active0/1Active state (fans, etc.)

Using the Scripts

For convenience, use the provided scripts:

List Accessories

scripts/homebridge_api.py list
scripts/homebridge_api.py list --room "Living Room"
scripts/homebridge_api.py list --type Lightbulb

Control Devices

# Turn on/off
scripts/homebridge_api.py set <uniqueId> On true
scripts/homebridge_api.py set <uniqueId> On false

# Adjust brightness
scripts/homebridge_api.py set <uniqueId> Brightness 75

# Set color
scripts/homebridge_api.py set <uniqueId> Hue 120
scripts/homebridge_api.py set <uniqueId> Saturation 100

Get Accessory Status

scripts/homebridge_api.py get <uniqueId>

Tips

  • Find your accessory's uniqueId by listing all accessories first
  • The API documentation at /swagger shows all available endpoints
  • Characteristic names are case-sensitive (use On not on)
  • Some accessories may have multiple services; check the response for service types
  • Token expires after some time; re-authenticate if you get 401 errors

版本历史

共 1 个版本

  • v0.1.0 当前
    2026-03-28 15:13 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

life-service

healthcheck

stellarhold170nt
使用 JSON 文件存储追踪饮水和睡眠
★ 11 📥 29,866
life-service

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 451 📥 226,992
life-service

Caldav Calendar

asleep123
使用 vdirsyncer + khal 同步并查询 CalDAV 日历(iCloud、Google、Fastmail、Nextcloud 等)。适用于 Linux。
★ 242 📥 30,437