← 返回 Skills 市场
maydayily

查询设备列表

作者 maydayily · GitHub ↗ · v1.0.5 · MIT-0
cross-platform ✓ 安全检测通过
177
总下载
0
收藏
0
当前安装
6
版本数
在 OpenClaw 中安装
/install api-device-list
功能描述
调用 ai-open-gateway 的设备列表查询接口 POST /api/device/list,获取当前用户绑定的所有设备信息。Use when: 需要查看绑定了哪些设备、获取设备 MAC 地址、确认设备是否已绑定。⚠️ 需设置 AI_GATEWAY_API_KEY。
使用说明 (SKILL.md)

设备列表查询接口

POST /api/device/list 用于查询当前认证用户绑定的所有设备列表。该接口无需请求体,设备列表由 api_key 自动关联。

⚠️ 展示规则(MUST 严格遵守)

脚本输出 JSON 格式的结构化数据,这是预期行为。以下展示规则是给 agent 的格式化指令:agent MUST 解析脚本输出的 JSON,按下述规则转换为用户友好的格式后再展示,MUST NOT 直接展示原始 JSON。

  1. code == 0data 非空时,以表格展示:
MAC 地址 设备名称
aabbccddeeff 客厅摄像机

关键规则:device_id MUST 去掉 xxxxS_ 前缀再展示为 MAC 地址。表头 MUST 写"MAC 地址",不要写"设备 ID"。

  1. data 为空数组时,回复:"当前账户下没有绑定任何设备。"
  2. code != 0 时,回复:"接口调用失败,错误码 {code},原因:{message}"

前置依赖

脚本依赖 httpx。如果未安装,脚本会提示 python3 -m pip install httpx

配置声明

本 skill 依赖以下配置项,agent 和用户 MUST 在运行前确认已正确配置。

必需配置

配置项 传递方式 说明
AI_GATEWAY_API_KEY 环境变量(推荐)、~/.openclaw/.env(fallback)、命令行 --api-key API 密钥,用于接口鉴权。脚本按此优先级自动获取

可选配置

配置项 传递方式 默认值 说明
AI_GATEWAY_HOST 环境变量、~/.openclaw/.env https://ai-open-gateway.closeli.cn 网关地址
AI_GATEWAY_VERIFY_SSL 环境变量 true 设为 false 可禁用 TLS 证书验证(仅限开发环境)
AI_GATEWAY_NO_ENV_FILE 环境变量 false 设为 true 可禁用 ~/.openclaw/.env fallback 读取(生产环境推荐)

Fallback 配置路径

脚本默认会读取 ~/.openclaw/.env 文件作为 fallback 配置源。该文件为所有 skill 共享,格式为 KEY=VALUE(每行一条)。生产环境 MUST 设置 AI_GATEWAY_NO_ENV_FILE=true 禁用此 fallback,改为通过环境变量直接传递所有配置。

安全注意事项

  • 共享凭证文件 ~/.openclaw/.env 可被同一用户下所有 skill 读取。生产环境 MUST 通过环境变量传递 API_KEY,MUST NOT 依赖共享凭证文件
  • TLS 证书验证默认启用,MUST NOT 在生产环境禁用(禁用会导致中间人攻击风险,攻击者可截获 API_KEY 和设备数据)
  • 使用前 MUST 确认 AI_GATEWAY_HOST 指向可信域名
  • MUST 使用最小权限的 API_KEY,避免复用高权限凭证。本 skill 仅需设备列表查询权限

网络访问声明

本 skill 仅访问以下端点(均为 AI_GATEWAY_HOST 下的路径):

端点 方法 用途
/api/device/list POST 查询用户绑定的设备列表

脚本不访问任何其他网络资源。

快速开始

python3 list_devices.py

认证方式

使用 Bearer Token 认证,脚本自动在请求头中携带 Authorization: Bearer \x3Capi_key>

请求格式

请求头

参数名 类型 必填 说明
Content-Type string application/json
Authorization string Bearer \x3Capi_key>,32 位十六进制字符串

请求体

无需请求体。

响应格式

{
  "code": 0,
  "message": "success",
  "request_id": "\x3C32位请求追踪ID>",
  "data": [
    {
      "device_id": "xxxxS_aabbccddeeff",
      "device_name": "客厅摄像机"
    }
  ]
}

data 字段(设备数组)

参数名 类型 说明
device_id string 设备 ID,格式: xxxxS_\x3Cmac地址>,后续接口均使用此格式
device_name string 设备名称,用户自定义的设备别名

错误码

错误码 HTTP 状态码 说明
1001 401 未提供 api_key(缺少 Authorization 头或格式不正确)
1002 401 api_key 无效或已禁用
3001 502 网关内部服务调用失败
3004 502 网关内部服务调用失败
5000 500 内部错误

注意事项

  • device_id 格式为 xxxxS_\x3Cmac>,是后续所有设备相关接口的标识符
  • 全局请求超时为 120 秒
安全使用建议
This skill appears to do exactly what it says: call POST /api/device/list using the provided AI_GATEWAY_API_KEY. Before installing/using: (1) Supply a dedicated, least-privilege API key (do not reuse a high-privilege key). (2) Prefer setting AI_GATEWAY_API_KEY as an environment variable and set AI_GATEWAY_NO_ENV_FILE=true in production to avoid reading the shared ~/.openclaw/.env fallback. (3) Verify AI_GATEWAY_HOST points to the expected, trusted domain and do not disable TLS verification in production. (4) The script requires python3 and the httpx package; run it in a controlled environment. (5) Ensure the agent presenting results follows the SKILL.md rule to format the JSON output (table or user-friendly message) and not leak raw JSON or credentials.
功能分析
Type: OpenClaw Skill Name: api-device-list Version: 1.0.5 The skill is a standard API client for querying a device list from the 'ai-open-gateway' service (closeli.cn). It follows documented patterns for credential management (environment variables or a shared .env file) and includes clear instructions for the AI agent on how to format the output. No malicious behaviors, data exfiltration to unauthorized endpoints, or obfuscation were detected in list_devices.py or SKILL.md.
能力评估
Purpose & Capability
Name/description, required env var (AI_GATEWAY_API_KEY), required binary (python3), and code all directly relate to calling POST /api/device/list on an ai-open-gateway host. Optional env vars (AI_GATEWAY_HOST, AI_GATEWAY_VERIFY_SSL, AI_GATEWAY_NO_ENV_FILE) are appropriate for configuring the gateway and TLS behavior.
Instruction Scope
SKILL.md instructs the agent to run the included script and to parse the JSON output into a user-friendly table. The script prints only the API response JSON and does not access other system files besides the declared ~/.openclaw/.env fallback. The documented rule that the agent must not display raw JSON but instead format results is consistent with the script's behavior.
Install Mechanism
No install spec is provided (instruction-only), and the only runtime dependency is the Python package httpx; the script prints a clear error with pip install instructions if httpx is missing. No downloads from untrusted URLs or archive extraction are present.
Credentials
Only AI_GATEWAY_API_KEY is required as a primary credential, which is proportionate. The script also optionally reads ~/.openclaw/.env as a fallback (declared in SKILL.md). This shared fallback file is a legitimate convenience but creates a cross-skill credential sharing risk; the skill documents this and exposes an env toggle (AI_GATEWAY_NO_ENV_FILE) to disable the fallback.
Persistence & Privilege
The skill does not request permanent presence (always:false), does not modify other skills or system-wide settings, and has no install-time side effects. It runs as a one-off script and uses environment/config inputs only.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api-device-list
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api-device-list 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.5
- Added a metadata block declaring required runtime (python3) and main environment variable (AI_GATEWAY_API_KEY). - No other functional or behavioral changes.
v1.0.4
api-device-list 1.0.4 - 增加可选配置项 AI_GATEWAY_NO_ENV_FILE,允许通过环境变量设置为 true 禁用 ~/.openclaw/.env fallback 读取,提升生产环境安全性。 - 更新配置说明和安全建议,明确生产环境应采用 AI_GATEWAY_NO_ENV_FILE=true,仅通过环境变量传递配置。
v1.0.3
Version 1.0.3 - Clarified configuration section by explicitly listing required and optional configuration options and their sources. - Added "配置声明"部分,明确技能依赖的所有配置项及其优先级和传递方式。 - Enhanced security instructions, discouraging the use of shared credential files in production environments and emphasizing least-privilege principle for API keys. - No changes to interface or core logic.
v1.0.2
api-device-list 1.0.2 Changelog - 展示规则优化:明确 agent 必须解析脚本输出 JSON 并用户友好地格式化显示,不能展示原始 JSON 响应。 - 技术依赖调整:明示脚本依赖 httpx,并给出未安装时的安装提示。 - 配置与凭证说明简化:环境变量、HOST 地址、TLS 验证等凭证与安全条款更加清晰。 - 网络声明强化:详细说明只访问 /api/device/list,增强安全可靠性。 - SKILL.md 结构精简与规范性提升,更利于用户和开发者理解和配置使用。
v1.0.1
api-device-list 1.0.1
v1.0.0
Initial release: Provides a Python script for querying all devices bound to a user via the ai-open-gateway service. - Added list_devices.py script to call POST /api/device/list and format output as a MAC/Name table. - Supports API key input via environment variable, .env file, or command line parameter. - Returns friendly messages for empty device lists or API errors. - Includes detailed SKILL.md setup, usage instructions, and integration scenarios.
元数据
Slug api-device-list
版本 1.0.5
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 6
常见问题

查询设备列表 是什么?

调用 ai-open-gateway 的设备列表查询接口 POST /api/device/list,获取当前用户绑定的所有设备信息。Use when: 需要查看绑定了哪些设备、获取设备 MAC 地址、确认设备是否已绑定。⚠️ 需设置 AI_GATEWAY_API_KEY。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 177 次。

如何安装 查询设备列表?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install api-device-list」即可一键安装,无需额外配置。

查询设备列表 是免费的吗?

是的,查询设备列表 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

查询设备列表 支持哪些平台?

查询设备列表 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 查询设备列表?

由 maydayily(@maydayily)开发并维护,当前版本 v1.0.5。

💬 留言讨论