360 Secure SkillHub
360 安全技能中心

openclaw-smartpi-setup

该 Skill 面向 OpenClaw 环境,指导 Agent 通过 OpenClaw CLI 完成 SmartPi 设备的绑定、列出与删除,生成并发送绑定二维码,等待 WebSocket 连接成功;同时提供连接与 AI 响应超时(9002)的分步排查方法,以及 plugins.allow、channels 配置的关键注意事项。

分类:自动化
fengseven777
fengseven777
热度 4.26
最近更新 2026-05-21 16:36:08

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add fengseven777/smartpi-plugin-setup
兼容性
OpenClaw 专属
联网要求
需要联网
数据出网
数据出网未确认
Metadata
name
openclaw-smartpi-setup
description
SmartPi 设备绑定、扫码、设备管理与 9002 故障排查。触发词:绑定 SmartPi、9002、SmartPi 连接失败、查看 SmartPi 设备、删除 SmartPi 设备。

openclaw-smartpi-setup

用户意图 → Agent 动作

用户说 Agent 立即执行
绑定/添加 SmartPi 设备 执行 bind → 生成二维码 → 等待 WebSocket connected
查看/列出 SmartPi 设备 exec: openclaw smartpi accounts list
删除 SmartPi 设备 exec: openclaw smartpi accounts remove <deviceKey>

绑定流程

  1. exec: openclaw smartpi accounts bind
  2. 从输出提取 绑定ID: 后的 bindingId
  3. 生成 QR PNG(脚本见下)
  4. 发送图片给用户,提示「用微信扫一扫,绑定成功我会告诉你」
  5. 等待 30-120 秒,查日志 WebSocket connected: <deviceKey>
  6. 确认连接后告知用户「设备已连接,可以对着 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 未在限定时间内回复。按顺序排查:

  1. exec: openclaw plugins list → 确认 openclaw-smartpi: enabled
  2. exec: openclaw smartpi accounts list → 确认有设备
  3. 查日志 WebSocket connected → 确认 WS 已连接
  4. 向 OpenClaw 发一条文本 → 确认 AI 响应速度正常(最常见原因:本地模型慢 / MCP 阻塞 / Tools 卡住)
  5. 查日志 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