Xpersona
M

Mqtt Client

CLAWHUB · Unverified

Universal MQTT Client for OpenClaw with Node.js/mqtt.js. Enables Connection Management, Subscription Management, Message Handling and OpenClaw Integration fo... Skill: Mqtt Client Owner: sanwebgit Summary: Universal MQTT Client for OpenClaw with Node.js/mqtt.js. Enables Connection Management, Subscription Management, Message Handling and OpenClaw Integration fo... Tags: latest:1.2.2 Version history: v1.2.2 | 2026-03-24T01:46:01.928Z | user Republish current version v1.2.1 | 2026-03-24T01:41:39.926Z | user Reverted to localhost default for cleaner security scan v1.2.0 | 2026-

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s1716q5ac0tac8855fb0f7k2g183f7jr:mqtt-client-openclaw
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-sanwebgit-mqtt-client-openclaw/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

133,601 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

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

```bash
npm install mqtt
```

### Minimal Example

```javascript
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

| Variable | Default | Description |
|----------|---------|-------------|
| `MQTT_BROKER` | `localhost` | Broker URL (with or without protocol) |
| `MQTT_BROKER_PORT` | `1883` | Broker port |
| `MQTT_USERNAME` | - | Username (optional) |
| `MQTT_PASSWORD` | - | Password (optional) |
| `MQTT_CLIENT_ID` | auto-generated | Client ID (max 23 chars) |
| `MQTT_SUBSCRIBE_TOPIC` | `#` | Default topic to subscribe |
| `MQTT_KEEPALIVE` | `60` | Keep-alive interval (seconds) |
| `MQTT_RECONNECT_PERIOD` | `5000` | Reconnect interval (ms) |

### Auto-Setup

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

```json
{
  "skills": {
    "entries": {
      "mqtt-client": {
        "enabled": true,
        "env": {
          "MQTT_BROKER": "localhost",
          "MQTT_BROKER_PORT": "1883"
        }
      }
    }
  }
}
```

> ⚠️ Existing values are NOT overwritten.

---

## 🔌 Connection Management

### Auto-Reconnect

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

### Keep-Alive

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

### LWT (Last Will & Testament)

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

### Graceful Disconnect

```javascript
await client.disconnect();  // with timeout
await clien

README.md

# MQTT Client Skill for OpenClaw

> Production-ready, universal MQTT client with auto-reconnect, triggers, and health monitoring.

## Features

- 🔌 **Connection Management** - Auto-reconnect, Keep-Alive, LWT, Graceful disconnect
- 📬 **Subscription Management** - Wildcards (`+`, `#`), QoS levels (0/1/2), dynamic subscribe/unsubscribe
- 📤 **Message Handling** - Publish, retained messages, automatic JSON parsing
- ⚡ **Threshold Triggers** - React to value changes (e.g., battery < 10%, temperature > 30°C)
- 📊 **Health Monitoring** - Connection status, latency, message statistics
- 💾 **Message History** - Last N messages per topic
- 🔒 **Security** - TLS support, credentials from config

## Quick Start

```bash
npm install mqtt
```

```javascript
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

| Variable | Default | Description |
|----------|---------|-------------|
| `MQTT_BROKER` | localhost | Broker URL |
| `MQTT_BROKER_PORT` | 1883 | Broker port |
| `MQTT_USERNAME` | - | Username (optional) |
| `MQTT_PASSWORD` | - | Password (optional) |
| `MQTT_CLIENT_ID` | auto | Client ID |
| `MQTT_SUBSCRIBE_TOPIC` | # | Default topic |

Auto-configured in `~/.openclaw/openclaw.json` on first use.

## Threshold Triggers

React to value changes automatically:

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

Supported operators: `>`, `<`, `>=`, `<=`, `==`, `!=`, `contains`, `startsWith`

## API

### Constructor Options

- `broker` - MQTT Broker URL
- `username` / `password` - Auth (optional)
- `clientId` - Custom client ID
- `reconnectPeriod` - Reconnect interval (ms)
- `keepalive` - Keep-alive interval (s)
- `messageHistorySize` - Max history entries
- `parseJson` - Auto JSON parse

### Methods

| Method | Description |
|--------|-------------|
| `connect()` | Establish connection |
| `disconnect()` | Graceful disconnect |
| `subscribe(topic, opts)` | Subscribe |
| `unsubscribe(topic)` | Unsubscribe |
| `publish(topic, payload, opts)` | Publish message |
| `getMessageHistory(topic)` | Get message history |
| `getHealth()` | Health status |
| `addTrigger(id, config)` | Add threshold trigger |

## Resources

- `scripts/mqtt-client.js` - Main library
- `references/mqtt-topics.md` - Topic naming conventions

## License

MIT-0 (No Attribution Required) - See [LICENSE](scripts/mqtt-client.js) for full text.

## Links

- [mqtt.js Documentation](https://github.com/mqttjs/MQTT.js)
- [MQTT 5.0 Specification](ht

_meta.json

{
  "ownerId": "kn76gkch1n3amve9zm7me6kwpn83718t",
  "slug": "mqtt-client-openclaw",
  "version": "1.2.2",
  "publishedAt": 1774316761928
}

references/mqtt-topics.md

# MQTT Topics Best Practices

## Topic Structure

### Standard MQTT Topic Hierarchy

```
<root>/<device_type>/<device_name>/<property>
```

### Recommended Prefixes

| Prefix | Usage |
|--------|-------|
| `zigbee2mqtt/` | Zigbee2MQTT devices |
| `homie/` | Homie Convention devices |
| `homeassistant/` | Home Assistant |
| `tasmota/` | Tasmota devices |
| `openclaw/` | OpenClaw own topics |

## Zigbee2MQTT Topics

### Bridge Topics

```
zigbee2mqtt/bridge/info           # Bridge information
zigbee2mqtt/bridge/state          # Bridge status (online/offline)
zigbee2mqtt/bridge/log            # Bridge logs
zigbee2mqtt/bridge/request/info   # Request info
zigbee2mqtt/bridge/request/devices # Request device list
zigbee2mqtt/bridge/permit_join    # Allow device join
zigbee2mqtt/bridge/remove/<id>    # Remove device
zigbee2mqtt/bridge/rename/<id>   # Rename device
```

### Device Topics

```
zigbee2mqtt/<friendly_name>       # Device status (JSON)
zigbee2mqtt/<friendly_name>/set   # Control device
zigbee2mqtt/<friendly_name>/get   # Query value
zigbee2mqtt/<friendly_name>/availability  # Online/Offline status
```

## Control Commands

### On/Off

```json
// Publish to <device>/set
{ "state": "ON" }
{ "state": "OFF" }
{ "toggle": "" }
```

### Brightness

```json
{ "brightness": 0-255 }
{ "brightness": 50 }  // ~20%
```

### Color (RGB)

```json
{ "color": { "r": 255, "g": 128, "b": 0 } }
```

### Color Temperature

```json
{ "color_temp": 370 }  // Kelvin (warm to cool)
```

### Color (XY)

```json
{ "color": { "x": 0.5, "y": 0.5 } }
```

## Sensors

### Temperature

```json
{
  "temperature": 23.5,
  "humidity": 45,
  "pressure": 1013
}
```

### Motion

```json
{
  "occupancy": true,
  "occupancy_timeout": 60
}
```

### Battery

```json
{ "battery": 85 }
```

## QoS Recommendations

| QoS | Use Case |
|-----|-----------|
| 0 | Status updates, sensor values (loss acceptable) |
| 1 | Control commands (must arrive) |
| 2 | Critical commands (exactly once) |

## Retained Messages

- **Bridge State**: retain=true
- **Device Status**: retain=true
- **Sensor Data**: retain=false (too many updates)
- **Control Commands**: retain=false

## LWT (Last Will & Testament)

Recommended LWT topics:

```
openclaw/client/<clientId>/status  # Online/Offline
zigbee2mqtt/bridge/status          # Bridge online
```

LWT payload:
```json
{ "status": "offline", "reason": "unexpected", "timestamp": "..." }
```

## Error Codes

| Code | Description |
|------|-------------|
| `-32600` | Invalid JSON |
| `-32601` | Method not found |
| `-32602` | Invalid params |
| `-32603` | Internal error |

skill-card.md

## 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.

This skill is ready for commercial/non-commercial use.

## Publisher:

[sanwebgit](https://clawhub.ai/user/sanwebgit)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and automation engineers use this skill to connect OpenClaw agents to MQTT brokers, subscribe to topics, publish messages, monitor health, and trigger actions from MQTT state changes.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill can handle MQTT credentials and persistent OpenClaw configuration in ways that may weaken or redirect secure connections.

Mitigation: Review before installing, use least-privilege MQTT accounts, secure ~/.openclaw/openclaw.json permissions, pin dependencies, and fix TLS certificate verification before using real credentials.

Risk: Broad MQTT subscriptions such as the # wildcard can expose more broker traffic than intended.

Mitigation: Avoid # except on trusted scoped brokers and prefer narrowly scoped topic filters for production automation.

Risk: Running the skill from untrusted project directories can expose local configuration behavior to untrusted files or workflows.

Mitigation: Run it only from trusted workspaces and review configuration changes before deployment.

## Reference(s):

- [MQTT Topics Best Practices](references/mqtt-topics.md)
- [mqtt.js Documentation](https://github.com/mqttjs/MQTT.js)
- [MQTT 5.0 Specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html)

## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]

**Output Format:** [Markdown with JavaScript, JSON, and shell code blocks]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May include MQTT topic patterns, environment variables, OpenClaw configuration, and usage examples.]

## Skill Version(s):

1.2.2 (source: ClawHub release metadata)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Mqtt Client and adjacent AI workflows.