Token导航 LogoToken导航TokenDH.com
开发敏感数据clawhub未标认证来源可访问clear审计通过

mqtt-client-openclawmqtt client OpenClaw 开发

Agent Skill

mqtt-client-openclaw 用于补充开发相关能力,适合在 OpenClaw 中需要让 Agent 承接开发相关任务时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

6,614

周安装

265

GitHub Stars

1

下载量

2,141
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:mqtt-client-openclaw(mqtt client OpenClaw 开发)
来源仓库:https://github.com/sanwebgit/mqtt-client-openclaw
安装命令:
openclaw skills install mqtt-client-openclaw
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install mqtt-client-openclaw

简介

提供 Node.js/mqtt.js 封装的通用 MQTT 客户端,支持消息订阅与发布。

  • 集成连接管理与错误重试机制,便于 IoT 设备通信系统开发。
  • 开发者可直接调用 connect、subscribe 等方法实现轻量级消息交互。
  • 安装命令:openclaw skills install mqtt-client-openclaw,需指定 broker URL 与认证凭据。
  • 适用宿主包括 OpenClaw,接入前应确认版本、权限和运行环境要求。

SKILL.md

name
mqtt-client
description
Universal MQTT Client for OpenClaw with Node.js/mqtt.js. Enables Connection Management, Subscription Management, Message Handling and OpenClaw Integration for arbitrary MQTT-based automation.

📡 MQTT OpenClaw Skill

Production-ready MQTT client for OpenClaw automation. Universal - not bound to specific systems.

Universal MQTT Client for OpenClaw with Node.js/mqtt.js. Connect to any MQTT broker to subscribe to topics, publish messages, and react to state changes. The client automatically handles reconnection, supports wildcards for flexible topic patterns, and can trigger alerts when values cross thresholds (e.g., battery below 10% or temperature above 30°C). Use this skill to integrate OpenClaw with smart home systems such as ioBroker, Home Assistant, Zigbee2MQTT, Shelly devices, other OpenClaw instances (to communicate between them), or any other MQTT-based system.


🚀 Quick Start

Prerequisites

npm install mqtt

Minimal Example

const { MqttClient } = require('./scripts/mqtt-client.js');

const client = new MqttClient({
  broker: process.env.MQTT_BROKER,
  username: process.env.MQTT_USERNAME,
  password: process.env.MQTT_PASSWORD
});

client.on('message', (topic, payload) => console.log(`${topic}: ${payload}`));

await client.connect();
await client.subscribe('home/#');

⚙️ Configuration

Environment Variables

VariableDefaultDescription
MQTT_BROKERlocalhostBroker URL (with or without protocol)
MQTT_BROKER_PORT1883Broker port
MQTT_USERNAME-Username (optional)
MQTT_PASSWORD-Password (optional)
MQTT_CLIENT_IDauto-generatedClient ID (max 23 chars)
MQTT_SUBSCRIBE_TOPIC#Default topic to subscribe
MQTT_KEEPALIVE60Keep-alive interval (seconds)
MQTT_RECONNECT_PERIOD5000Reconnect interval (ms)

Auto-Setup

When first used, the skill automatically creates config in ~/.openclaw/openclaw.json:

{
  "skills": {
    "entries": {
      "mqtt-client": {
        "enabled": true,
        "env": {
          "MQTT_BROKER": "localhost",
          "MQTT_BROKER_PORT": "1883"
        }
      }
    }
  }
}
⚠️ Existing values are NOT overwritten.

🔌 Connection Management

Auto-Reconnect

const client = new MqttClient({
  broker: 'mqtt://localhost:1883',
  reconnectPeriod: 5000,
  connectTimeout: 30000,
  maxReconnectAttempts: 10
});

Keep-Alive

const client = new MqttClient({
  broker: 'mqtt://localhost:1883',
  keepalive: 60  // seconds
});

LWT (Last Will & Testament)

const client = new MqttClient({
  will: {
    topic: 'openclaw/status',
    payload: JSON.stringify({ status: 'offline' }),
    qos: 1,
    retain: true
  }
});

Graceful Disconnect

await client.disconnect();  // with timeout
await client.disconnect(5000);

📬 Subscription Management

Basic Subscribe

// Single topic
await client.subscribe('home/bridge/info');

// Multiple topics
await client.subscribe(['home/bridge/info', 'home/bridge/state']);

Wildcards

WildcardDescriptionExample
+Single levelhome/+/temperature
#Multi levelhome/sensors/#

QoS Levels

LevelNameDescription
0At most onceFire and forget
1At least onceAcknowledged delivery
2Exactly onceHandshake protocol
await client.subscribe('topic', { qos: 2 });

Dynamic Subscribe/Unsubscribe

await client.subscribe('new/topic');
await client.unsubscribe('old/topic');
await client.unsubscribeAll();

📤 Message Handling

Publish

// Simple
await client.publish('home/lights/set', 'ON');

// With options
await client.publish('home/lights/set', 'ON', { qos: 1, retain: true });

// As JSON (auto-stringified)
await client.publish('home/lights/set', { state: 'ON', brightness: 255 });

Retained Messages

// Set retained
await client.publish('home/announcement', 'Hello', { retain: true });

// Delete retained (empty payload)
await client.publish('home/announcement', '', { retain: true });

JSON Parsing

Automatic parsing - payload is already an object for JSON messages:

client.on('message', (topic, payload) => {
  if (typeof payload === 'object') {
    console.log('JSON:', payload.key);
  }
});

🔔 Threshold Triggers

React to value changes with triggers:

// Battery low trigger
client.addTrigger('battery-low', {
  topic: 'home/+/battery',
  path: 'value',
  operator: '<',
  threshold: 10,
  valueType: 'number',
  cooldown: 60000,
  callback: (event) => console.log('⚠️ Low battery:', event.value)
});

// Temperature high trigger
client.addTrigger('temp-high', {
  topic: 'home/sensors/+/temperature',
  path: 'value',
  operator: '>',
  threshold: 30,
  valueType: 'number',
  callback: (event) => console.log('🔥 Hot:', event.value)
});

Trigger Operators

OperatorDescription
>Greater than
<Less than
>=Greater or equal
<=Less or equal
==Equal
!=Not equal
containsString contains
startsWithString starts with

📊 Health & State

Get Health Status

const health = client.getHealth();
// { connected, reconnecting, lastConnected, messagesReceived, latency }

Get Current State

const state = client.getState();
// { status, broker, subscriptions }

Message History

// Last messages for topic
const history = client.getMessageHistory('home/+/temperature');

// Last message
const last = client.getLastMessage('home/sensors/#');

// Clear history
client.clearHistory();

📋 API Reference

Constructor Options

OptionTypeDefaultDescription
brokerstringenvMQTT Broker URL
usernamestringenvUsername
passwordstringenvPassword
clientIdstringautoClient ID
reconnectPeriodnumber5000Reconnect interval (ms)
connectTimeoutnumber30000Connection timeout (ms)
keepalivenumber60Keep-alive (s)
messageHistorySizenumber50Max history entries
parseJsonbooleantrueAuto JSON parse
logLevelstringinfodebug/info/warn/error

Methods

MethodDescription
connect()Establish connection
disconnect([ms])Graceful disconnect
subscribe(topic, opts)Subscribe to topic(s)
unsubscribe(topic)Unsubscribe
publish(topic, payload, opts)Publish message
getMessageHistory([topic])Get message history
getHealth()Health status
getState()Current state
isConnected()Connection check
addTrigger(id, config)Add threshold trigger
removeTrigger(id)Remove trigger
getTriggers()List triggers

Events

EventDescription
connectSuccessfully connected
disconnectDisconnected
messageMessage received (topic, payload, packet)
errorError occurred
offlineClient offline
reconnectingAttempting reconnect
reconnectSuccessfully reconnected

📁 Resources

scripts/

  • mqtt-client.js - Main library

references/

  • mqtt-topics.md - Topic naming conventions

🔗 External Links

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

87.96%
按下载量换算1,883

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills