计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
homekit【效率与协作】Control Apple HomeKit smart home devices. Supports listing, discovering, pairing devices, and controlling lights, switches, outlets, thermostats. Use when the user needs to manage HomeKit accessories programmatically. Requires homekit library and paired devices.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
通过 Python 脚本控制苹果 HomeKit 智能家居设备。
pip3 install HAP-python homekit --user
首次使用前需要配对设备:
# 发现设备
python3 scripts/homekit.py discover
# 配对设备
python3 scripts/homekit.py pair "设备名称" "XXX-XX-XXX" "别名"
配对码通常在设备说明书或设备本体上(格式:XXX-XX-XXX)。
python3 scripts/homekit.py list
输出示例:
📱 找到 3 个设备:
Alias Name Type Status
----------------------------------------------------------------------
💡 living-light 客厅主灯 Lightbulb on (80%)
🔌 desk-outlet 桌面插座 Outlet off
💡 bedroom-lamp 床头灯 Lightbulb off
打开设备:
python3 scripts/homekit.py on living-light
关闭设备:
python3 scripts/homekit.py off living-light
调节亮度(0-100):
python3 scripts/homekit.py brightness living-light 50
python3 scripts/homekit.py status living-light
发现新设备:
python3 scripts/homekit.py discover --timeout 10
取消配对:
python3 scripts/homekit.py unpair living-light
| 类型 | 支持操作 |
|---|---|
| 💡 Lightbulb | 开关、亮度调节 |
| 🔌 Outlet | 开关 |
| 🔲 Switch | 开关 |
| 🌡️ Thermostat | 查看温度、设置目标温度 |
| 🌀 Fan | 开关、风速调节 |
错误:homekit 库未安装
→ 运行: pip3 install HAP-python homekit --user
错误:未找到设备 → 确保设备和电脑在同一 WiFi 网络
错误:配对失败 → 检查配对码是否正确,设备是否处于配对模式
设备显示离线 → 尝试重新配对或检查设备电源
# 关闭所有灯
for device in living-light bedroom-lamp kitchen-light; do
python3 scripts/homekit.py off $device
done
创建 ~/scripts/goodnight.sh:
#!/bin/bash
# 晚安场景:关闭所有灯,保留床头灯微光
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 "晚安 😴"