iot-protocols

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

iot-protocols

IoT协议

Purpose

用途

This skill provides tools for interacting with IoT protocols like Zigbee, Z-Wave, LoRaWAN, CoAP, Matter, and Thread, enabling device connectivity, data exchange, and network management in IoT applications.
本技能提供了与Zigbee、Z-Wave、LoRaWAN、CoAP、Matter和Thread等IoT协议交互的工具,可在IoT应用中实现设备连接、数据交换和网络管理。

When to Use

使用场景

Use this skill when building IoT systems requiring low-power, mesh networking (e.g., Zigbee for smart homes), long-range communication (e.g., LoRaWAN for sensors in remote areas), or lightweight protocols (e.g., CoAP for constrained devices). Apply it in scenarios like smart home automation, industrial IoT monitoring, or interoperable ecosystems with Matter.
当你构建需要低功耗网状网络(例如用于智能家居的Zigbee)、长距离通信(例如用于偏远地区传感器的LoRaWAN)或轻量级协议(例如用于受限设备的CoAP)的IoT系统时,可使用本技能。适用于智能家居自动化、工业IoT监控或基于Matter的互操作生态系统等场景。

Key Capabilities

核心功能

  • Establish connections to devices using specific protocols: e.g., Zigbee for mesh networks or Thread for IPv6-based low-power wireless.
  • Send/receive data payloads: e.g., query sensor data via CoAP or control Z-Wave devices.
  • Configure network settings: e.g., set up LoRaWAN gateways or Matter fabric bridges.
  • Handle protocol-specific features: e.g., Zigbee's binding for device pairing or LoRaWAN's adaptive data rate.
  • Interoperate across protocols: e.g., bridge Matter devices with Thread networks for seamless integration.
  • 使用特定协议建立与设备的连接:例如,用于网状网络的Zigbee或基于IPv6的低功耗无线协议Thread。
  • 发送/接收数据载荷:例如,通过CoAP查询传感器数据或控制Z-Wave设备。
  • 配置网络设置:例如,设置LoRaWAN网关或Matter fabric网桥。
  • 处理协议特定特性:例如,Zigbee的设备配对绑定功能或LoRaWAN的自适应数据速率。
  • 跨协议互操作:例如,将Matter设备与Thread网络桥接以实现无缝集成。

Usage Patterns

使用模式

To accomplish tasks, always authenticate first by setting the environment variable
export IOT_API_KEY=your_api_key
. Start with the
openclaw iot init
command to initialize the session, then use subcommands for protocol-specific actions. For example, to connect to a device, specify the protocol and device ID; for data operations, use query flags. Always include error checking in scripts. Pattern:
openclaw iot <subcommand> --protocol <protocol> --device-id <id>
. Use JSON config files for complex setups, e.g., create a file named
config.json
with
{ "protocol": "zigbee", "networkKey": "hex_key" }
and pass it via
--config config.json
.
要完成任务,首先需要通过设置环境变量
export IOT_API_KEY=your_api_key
进行身份验证。使用
openclaw iot init
命令初始化会话,然后使用子命令执行特定协议的操作。例如,连接设备时,指定协议和设备ID;进行数据操作时,使用查询标志。脚本中始终要包含错误检查。模式:
openclaw iot <subcommand> --protocol <protocol> --device-id <id>
。对于复杂设置,使用JSON配置文件,例如创建名为
config.json
的文件,内容为
{ "protocol": "zigbee", "networkKey": "hex_key" }
,并通过
--config config.json
参数传入。

Common Commands/API

常用命令/API

Use the OpenClaw CLI for quick interactions or REST APIs for programmatic access. Authentication requires the
$IOT_API_KEY
header.
  • CLI Command: List protocols
    openclaw iot list --protocol zigbee

    This outputs available Zigbee devices; add
    --verbose
    for detailed network info.
  • CLI Command: Connect to a device
    openclaw iot connect --protocol lorawan --device-id 456 --region EU868

    Use this to establish a LoRaWAN connection; specify region flag for frequency bands.
  • API Endpoint: Send data via CoAP
    POST /api/iot/send
    Body:
    { "protocol": "coap", "endpoint": "/sensors/temp", "payload": "{\"temp\": 25}" }

    Include header:
    Authorization: Bearer $IOT_API_KEY
  • API Endpoint: Query Z-Wave status
    GET /api/iot/status?protocol=z-wave&device-id=789
    Response: JSON object like
    { "status": "online", "nodes": 5 }
    ; handle with a simple fetch in code:
    fetch('/api/iot/status', { headers: { 'Authorization': process.env.IOT_API_KEY } }) .then(response => response.json())
  • Config Format: For Matter integration, use a YAML file:
    matter-config.yaml: protocol: matter, fabricId: 12345, nodeId: 678

    Load it with:
    openclaw iot load-config --file matter-config.yaml
使用OpenClaw CLI进行快速交互,或使用REST API进行程序化访问。身份验证需要
$IOT_API_KEY
请求头。
  • CLI命令:列出协议设备
    openclaw iot list --protocol zigbee

    该命令输出可用的Zigbee设备;添加
    --verbose
    参数可获取详细网络信息。
  • CLI命令:连接设备
    openclaw iot connect --protocol lorawan --device-id 456 --region EU868

    使用该命令建立LoRaWAN连接;需指定
    region
    标志以设置频段。
  • API端点:通过CoAP发送数据
    POST /api/iot/send
    请求体:
    { "protocol": "coap", "endpoint": "/sensors/temp", "payload": "{\"temp\": 25}" }

    请求头需包含:
    Authorization: Bearer $IOT_API_KEY
  • API端点:查询Z-Wave状态
    GET /api/iot/status?protocol=z-wave&device-id=789
    响应:JSON对象,例如
    { "status": "online", "nodes": 5 }
    ;可在代码中使用简单的fetch处理:
    fetch('/api/iot/status', { headers: { 'Authorization': process.env.IOT_API_KEY } }) .then(response => response.json())
  • 配置格式:Matter集成使用YAML文件:
    matter-config.yaml: protocol: matter, fabricId: 12345, nodeId: 678

    通过以下命令加载:
    openclaw iot load-config --file matter-config.yaml

Integration Notes

集成说明

Integrate this skill with other OpenClaw tools by referencing the
iot
cluster in your workflow. For external systems, export
$IOT_API_KEY
and use it in API calls. To combine with a database skill, pipe output: e.g.,
openclaw iot get --protocol coap | openclaw db insert
. For Thread integration, ensure IPv6 compatibility in your network stack. Example: In a Node.js app, import OpenClaw SDK and call:
const openclaw = require('openclaw-sdk'); openclaw.iot.connect({ protocol: 'thread', deviceId: '101' });

Always validate inputs; for Zigbee, check mesh topology before connecting.
在工作流中通过引用
iot
集群,将本技能与其他OpenClaw工具集成。对于外部系统,导出
$IOT_API_KEY
并在API调用中使用。要与数据库技能结合,可通过管道传递输出:例如
openclaw iot get --protocol coap | openclaw db insert
。进行Thread集成时,确保你的网络栈支持IPv6。示例:在Node.js应用中,导入OpenClaw SDK并调用:
const openclaw = require('openclaw-sdk'); openclaw.iot.connect({ protocol: 'thread', deviceId: '101' });

始终要验证输入;对于Zigbee,连接前检查网状网络拓扑。

Error Handling

错误处理

Handle errors by checking CLI exit codes or API response status. Common errors include authentication failures (HTTP 401) or protocol mismatches (e.g., invalid Zigbee network key). Use try-catch in code:
try { await openclaw.iot.connect({ protocol: 'z-wave', deviceId: '202' }); } catch (error) { console.error(error.message); // e.g., "Device not found" }

For CLI, parse output: if
openclaw iot connect
returns non-zero, check stderr for messages like "Protocol not supported". Retry transient errors (e.g., LoRaWAN signal loss) with exponential backoff.
通过检查CLI退出代码或API响应状态来处理错误。常见错误包括身份验证失败(HTTP 401)或协议不匹配(例如无效的Zigbee网络密钥)。在代码中使用try-catch:
try { await openclaw.iot.connect({ protocol: 'z-wave', deviceId: '202' }); } catch (error) { console.error(error.message); // 例如:"Device not found" }

对于CLI,解析输出:如果
openclaw iot connect
返回非零值,检查stderr获取类似“Protocol not supported”的消息。对于临时错误(例如LoRaWAN信号丢失),使用指数退避策略重试。

Concrete Usage Examples

具体使用示例

  1. Set up a Zigbee mesh network: First, export your key:
    export IOT_API_KEY=abc123
    . Then, initialize:
    openclaw iot init --protocol zigbee
    . Connect devices:
    openclaw iot connect --protocol zigbee --device-id 303 --pan-id 0x1a62
    . Send a command to toggle a light:
    openclaw iot send --protocol zigbee --endpoint /lights/1 --payload '{"state": "on"}'
    . This establishes a mesh for home automation.
  2. Query data from a LoRaWAN sensor: Authenticate via env var, then:
    openclaw iot connect --protocol lorawan --device-id 404 --app-eui 70B3D57EF0000000
    . Retrieve data:
    openclaw iot get --protocol lorawan --payload-type temp
    . In code:
    openclaw.iot.get({ protocol: 'lorawan', deviceId: '404' }).then(data => console.log(data));

    This is useful for monitoring remote environmental sensors.
  1. 搭建Zigbee网状网络:首先导出密钥:
    export IOT_API_KEY=abc123
    。然后初始化:
    openclaw iot init --protocol zigbee
    。连接设备:
    openclaw iot connect --protocol zigbee --device-id 303 --pan-id 0x1a62
    。发送命令打开灯光:
    openclaw iot send --protocol zigbee --endpoint /lights/1 --payload '{"state": "on"}'
    。此操作可为智能家居搭建网状网络。
  2. 从LoRaWAN传感器查询数据:通过环境变量进行身份验证,然后执行:
    openclaw iot connect --protocol lorawan --device-id 404 --app-eui 70B3D57EF0000000
    。获取数据:
    openclaw iot get --protocol lorawan --payload-type temp
    。代码中实现:
    openclaw.iot.get({ protocol: 'lorawan', deviceId: '404' }).then(data => console.log(data));

    这适用于远程环境传感器监控。

Graph Relationships

关联关系

  • Related to: iot-cluster (for broader IoT management), networking-skills (for protocol-agnostic networking).
  • Depends on: security-skills (for encryption in protocols like Zigbee).
  • Connected via: iot tag, allowing cross-skill queries in OpenClaw's graph.
  • 相关技能:iot-cluster(用于更广泛的IoT管理)、networking-skills(用于协议无关的网络管理)。
  • 依赖技能:security-skills(用于Zigbee等协议的加密)。
  • 关联标签:iot,可在OpenClaw图谱中进行跨技能查询。