← Back to Skills Marketplace
maydayily

查询设备的状态

by maydayily · GitHub ↗ · v1.0.5 · MIT-0
cross-platform ✓ Security Clean
162
Downloads
0
Stars
0
Active Installs
6
Versions
Install in OpenClaw
/install closeli-device-status
Description
调用 ai-open-gateway 的设备状态查询接口 POST /api/device/status,批量查询设备在线或离线状态。Use when: 需要检查设备是否在线、批量监控设备状态。⚠️ 需设置 AI_GATEWAY_API_KEY。
README (SKILL.md)

设备状态查询接口

POST /api/device/status 用于批量查询设备的在线/离线状态。

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

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

脚本输出中包含 _device_names 字段(device_id → device_name 映射),用于展示设备名称。

  1. code == 0data 非空时,以表格展示:
设备名称 MAC 地址 状态
客厅摄像机 aabbccddeeff 🟢 在线
门口摄像机 112233445566 🔴 离线

关键规则:

  • _device_names 中查找 device_id 对应的设备名称,找不到则显示"未知设备"
  • device_id MUST 去掉 xxxxS_ 前缀再展示为 MAC 地址
  • 状态映射:"online"🟢 在线"offline"🔴 离线
  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 获取设备名称映射
/api/device/status POST 查询设备在线/离线状态

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

快速开始

python3 check_status.py --device-ids "xxxxS_aabbccddeeff"

查询多台设备(逗号分隔):

python3 check_status.py --device-ids "xxxxS_aabbccddeeff,xxxxS_112233445566"

请求格式

请求体

参数名 类型 必填 说明
device_ids string[] 设备 ID 列表,不能为空数组。格式: xxxxS_\x3Cmac>

响应格式

{
  "code": 0,
  "message": "success",
  "request_id": "\x3C32位请求追踪ID>",
  "data": {
    "xxxxS_aabbccddeeff": { "status": "online" },
    "xxxxS_112233445566": { "status": "offline" }
  },
  "_device_names": {
    "xxxxS_aabbccddeeff": "客厅摄像机",
    "xxxxS_112233445566": "门口摄像机"
  }
}

data 字段(Map 结构)

key 为 device_id,value 为状态对象:

参数名 类型 说明
status string 设备状态,值为 "online""offline"

错误码

错误码 HTTP 状态码 说明
1001 401 未提供 api_key
1002 401 api_key 无效或已禁用
2001 400 缺少必要参数(device_ids 为空数组)
3001 502 网关内部服务调用失败
3002 502 网关内部服务调用失败
3004 502 网关内部服务调用失败
5000 500 内部错误

注意事项

  • device_ids 不能为空数组,否则返回错误码 2001
  • 不属于当前用户的设备会被静默过滤,不会返回错误
  • 全局请求超时为 120 秒
Usage Guidance
This skill is coherent with its purpose, but before installing: 1) Provide a minimal-permission API key (only device-status access). 2) Avoid relying on the shared fallback file ~/.openclaw/.env in production — set AI_GATEWAY_NO_ENV_FILE=true and pass the key via environment variable. 3) Verify AI_GATEWAY_HOST is a trusted domain (the script defaults to https://ai-open-gateway.closeli.cn). 4) Keep TLS verification enabled (do not set AI_GATEWAY_VERIFY_SSL=false in production). 5) Ensure python3 and the httpx package are available. If you cannot confirm the gateway host or appropriate key permissions, limit use or inspect network traffic to confirm behavior.
Capability Analysis
Type: OpenClaw Skill Name: closeli-device-status Version: 1.0.5 The skill is a legitimate tool for querying IoT device status via the Closeli AI gateway. The Python script (check_status.py) implements standard API interaction logic using httpx, with clear configuration priorities and documented security considerations regarding the use of a shared environment file (~/.openclaw/.env). There is no evidence of data exfiltration, malicious execution, or harmful prompt injection; the instructions in SKILL.md are strictly focused on formatting the script's JSON output into a user-friendly table.
Capability Assessment
Purpose & Capability
Name/description match the implementation: the script calls /api/device/list and /api/device/status on an ai-open-gateway host. Declared requirements (python3, AI_GATEWAY_API_KEY) are appropriate for this functionality.
Instruction Scope
SKILL.md instructs the agent to run the included script, parse its JSON output and present a formatted table. The instructions and the script reference only the API key, optional host/SSL flags, and the fallback ~/.openclaw/.env file — all relevant to querying device status. There is no unrelated file access or network exfiltration in the instructions.
Install Mechanism
No install spec — instruction-only plus an included Python script. The script depends on the public httpx package (standard ecosystem dependency). Nothing is downloaded from arbitrary/unknown URLs or installed to unexpected locations.
Credentials
Only AI_GATEWAY_API_KEY is required (primary credential), with optional AI_GATEWAY_HOST/AI_GATEWAY_VERIFY_SSL/AI_GATEWAY_NO_ENV_FILE. The script supports a fallback read of ~/.openclaw/.env (declared in metadata). This is functionally reasonable but has a security implication: the shared .env file is readable by other skills for the same user. SKILL.md explicitly warns to prefer environment variables and to set AI_GATEWAY_NO_ENV_FILE=true in production; follow that guidance.
Persistence & Privilege
always:false and no attempts to modify other skills or system-wide agent configuration. The script only reads configuration and makes outbound requests to the declared gateway endpoints.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install closeli-device-status
  3. After installation, invoke the skill by name or use /closeli-device-status
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.5
- Added metadata field configPaths: ["~/.openclaw/.env"] to indicate the fallback configuration file path. - No functional or behavioral changes to the skill logic.
v1.0.4
Version 1.0.4 - 声明增加了 skill 配置元数据(metadata),包括对 python3 和环境变量 AI_GATEWAY_API_KEY 的依赖。 - 文档新增“配置声明”与“Fallback 配置路径”说明,强调如何优先获取和禁用 fallback 配置,并推荐生产环境做法。 - 安全注意事项明确要求 production 环境通过环境变量配置,不要依赖共享 .env 文件;突出最小权限要求。 - 说明增加 AI_GATEWAY_NO_ENV_FILE 环境变量,可用于禁用 .env 文件自动读取。 - 强化了 TLS 验证的生产环境必须性及风险提示。 - 其余 skill 行为与接口说明无变更。
v1.0.3
- No code or documentation changes detected in this version. - Version number updated to 1.0.3.
v1.0.2
- Clarified that script output is always JSON and added specific instructions for agents to format this output for users. - Added a detailed "网络访问声明" (network access statement), explicitly listing only two accessed endpoints. - Strengthened security notes: production must use environment variables for API key; must verify host domain; must not disable TLS in production. - Minor language corrections and highlighted critical MUST/NOBLE rules for better compliance and security awareness. - No API or functional behavior changes—documentation/usage clarifications only.
v1.0.1
- Improved documentation for device status API usage, emphasizing strict output formatting and updated environment variable options. - Clarified dependencies: script now requires httpx (install with pip if missing). - Strengthened security notes: recommend using environment variable for API key in production and clarify TLS handling. - Simplified credential explanation and removed redundant installation/config instructions from documentation. - The only code change is the addition of a compiled Python cache file (__pycache__/check_status.cpython-314.pyc).
v1.0.0
api-device-status skill v1.0.0 – Initial Release - Provides POST /api/device/status interface to batch check online/offline status of devices via ai-open-gateway. - Python-based script, installable via ClawHub or manual copy, no extra dependencies required. - Supports flexible API key configuration (env, .env file, or command line). - Strict output formatting rules: tabular display; standardized status icons; device name mapping. - Handles all error and edge cases with user-friendly messages. - Designed for bulk device status monitoring, with support for integration and scheduled checks.
Metadata
Slug closeli-device-status
Version 1.0.5
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 6
Frequently Asked Questions

What is 查询设备的状态?

调用 ai-open-gateway 的设备状态查询接口 POST /api/device/status,批量查询设备在线或离线状态。Use when: 需要检查设备是否在线、批量监控设备状态。⚠️ 需设置 AI_GATEWAY_API_KEY。 It is an AI Agent Skill for Claude Code / OpenClaw, with 162 downloads so far.

How do I install 查询设备的状态?

Run "/install closeli-device-status" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 查询设备的状态 free?

Yes, 查询设备的状态 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 查询设备的状态 support?

查询设备的状态 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 查询设备的状态?

It is built and maintained by maydayily (@maydayily); the current version is v1.0.5.

💬 Comments