← 返回
开发者工具

HomeKit Smart Home Control

Control Apple HomeKit smart home devices. Supports listing, discovering, pairing devices, and controlling lights, switches, outlets, thermostats. Use when th...
控制 Apple HomeKit 智能家居设备。支持设备列表、发现、配对,以及控制灯光、开关、插座和恒温器。
alphafactor
开发者工具 clawhub v1.0.6 2 版本 99434.2 Key: 无需
★ 5
Stars
📥 2,712
下载
💾 62
安装
2
版本
#homekit#latest

概述

HomeKit Smart Home Controller

Control Apple HomeKit smart home devices using Python scripts.

Features

  • 🔍 Discover unpaired devices
  • 🔗 Pair/Unpair devices
  • 📱 List all paired devices
  • 💡 Control light switches and brightness
  • 🔌 Control outlets and switches
  • 🌡️ View device status

Prerequisites

1. Install Dependencies

pip3 install HAP-python homekit --user

2. Pair Devices

Pair your devices before first use:

# Discover devices
python3 scripts/homekit.py discover

# Pair a device
python3 scripts/homekit.py pair "Device Name" "XXX-XX-XXX" "alias"

The pairing code is usually found in the device manual or on the device itself (format: XXX-XX-XXX).

Usage

List All Devices

python3 scripts/homekit.py list

Example output:

📱 Found 3 devices:

Alias           Name                      Type            Status
----------------------------------------------------------------------
💡 living-light  Living Room Light         Lightbulb       on (80%)
🔌 desk-outlet   Desk Outlet               Outlet          off
💡 bedroom-lamp  Bedside Lamp              Lightbulb       off

Control Devices

Turn on:

python3 scripts/homekit.py on living-light

Turn off:

python3 scripts/homekit.py off living-light

Set brightness (0-100):

python3 scripts/homekit.py brightness living-light 50

View Device Status

python3 scripts/homekit.py status living-light

Device Management

Discover new devices:

python3 scripts/homekit.py discover --timeout 10

Unpair a device:

python3 scripts/homekit.py unpair living-light

Supported Device Types

TypeSupported Operations
---------------
💡 LightbulbOn/Off, Brightness
🔌 OutletOn/Off
🔲 SwitchOn/Off
🌡️ ThermostatView temp, Set target temp
🌀 FanOn/Off, Speed

Troubleshooting

Error: homekit library not installed

→ Run: pip3 install HAP-python homekit --user

Error: Device not found

→ Ensure the device and computer are on the same WiFi network.

Error: Pairing failed

→ Check if the pairing code is correct and the device is in pairing mode.

Device shows offline

→ Try re-pairing or check device power.

Advanced Usage

Batch Control

# Turn off all lights
for device in living-light bedroom-lamp kitchen-light; do
    python3 scripts/homekit.py off $device
done

Scene Script Example

Create ~/scripts/goodnight.sh:

#!/bin/bash
# Goodnight Scene: Turn off all lights except a dim bedside lamp

python3 ~/.openclaw/workspace/homekit/scripts/homekit.py off living-light
python3 ~/.openclaw/workspace/homekit/scripts/homekit.py off kitchen-light
python3 ~/.openclaw/workspace/homekit/scripts/homekit.py brightness bedroom-lamp 10

echo "Goodnight 😴"

References

  • HomeKit Official Docs: https://developer.apple.com/homekit/
  • Library Docs: https://github.com/jlusiardi/homekit_python

版本历史

共 2 个版本

  • v1.0.6 当前
    2026-03-28 13:46 安全 安全
  • v1.0.5
    2026-03-26 21:17

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,779
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 920 📥 185,724
data-analysis

Tushare Pro

alphafactor
通过Tushare API获取中国股票和期货市场数据,支持股票行情、期货数据、公司基本面及宏观经济指标。适用于...
★ 25 📥 15,351