openclaw-smartpi-setup
用户意图 → Agent 动作
| 用户说 | Agent 立即执行 |
|---|---|
| 绑定/添加 SmartPi 设备 | 执行 bind → 生成二维码 → 等待 WebSocket connected |
| 查看/列出 SmartPi 设备 | exec: openclaw smartpi accounts list |
| 删除 SmartPi 设备 | exec: openclaw smartpi accounts remove <deviceKey> |
绑定流程
exec: openclaw smartpi accounts bind- 从输出提取
绑定ID:后的 bindingId - 生成 QR PNG(脚本见下)
- 发送图片给用户,提示「用微信扫一扫,绑定成功我会告诉你」
- 等待 30-120 秒,查日志
WebSocket connected: <deviceKey> - 确认连接后告知用户「设备已连接,可以对着 SmartPi 说话了」
生成 QR 脚本(选一种):
Python:
import qrcode
qrcode.make("bindingId").save("smartpi_qr.png")
Node.js:
node -e "require('qrcode').toFile('smartpi_qr.png','bindingId',{type:'png'},e=>e&&console.error(e))"
首次安装(插件未装时)
openclaw plugins install openclaw-smartpi
openclaw gateway restart
然后配置(两个关键坑,见下方「关键坑点」),再重启 Gateway。
9002 排查
9002 = AI 未在限定时间内回复。按顺序排查:
exec: openclaw plugins list→ 确认openclaw-smartpi: enabledexec: openclaw smartpi accounts list→ 确认有设备- 查日志
WebSocket connected→ 确认 WS 已连接 - 向 OpenClaw 发一条文本 → 确认 AI 响应速度正常(最常见原因:本地模型慢 / MCP 阻塞 / Tools 卡住)
- 查日志
cannot resolve agentId→ 确认 channels 配置存在
关键坑点(必须保留)
坑 1:plugins.allow 是整体替换
config.patch 对数组是整体替换,不是追加。必须先 gateway action=config.get 读取当前配置,构造完整数组再 patch。
坑 2:channels 也是整体替换
config.patch 传 channels.openclaw-smartpi 会覆盖掉其他已有 channel(discord、telegram 等)。必须保留所有已有 channels,再追加 openclaw-smartpi。
正确配置示例:
"channels": {
"openclaw-smartpi": {
"enabled": true,
"defaultAgentId": "main"
}
}
坑 3:channel.id 必须匹配
插件内部 channel.id = "openclaw-smartpi",配置中必须是 channels.openclaw-smartpi,一字不差,否则消息无法路由,报 cannot resolve agentId。
常用命令
| 命令 | 用途 |
|---|---|
openclaw smartpi accounts list |
查看已绑定设备 |
openclaw smartpi accounts bind |
扫码绑定新设备 |
openclaw smartpi accounts remove <deviceKey> |
删除设备(同时解绑云端) |
openclaw plugins list |
确认插件状态 |
openclaw gateway restart |
插件变更后重启 |
日志关键字
| 关键字 | 含义 |
|---|---|
WebSocket connected |
设备已上线 ✅ |
WebSocket disconnected |
设备断开 |
cannot resolve agentId |
缺少 channels.openclaw-smartpi 配置 |
AI response timeout |
AI 响应超时 → 导致 9002 |
