mqttasgi for Openclaw

An ASGI protocol server that bridges MQTT brokers with Django Channels, enabling real-time IoT integration with full ORM support.

sivulich
v1.0.1
Feb 21, 2026
0
0
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install mqttasgi

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install mqttasgi using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is mqttasgi?

mqttasgi is a specialized ASGI protocol server designed to bridge the gap between MQTT (via paho-mqtt) and Django Channels. Much like Daphne serves HTTP and WebSockets, mqttasgi allows your Django application to treat MQTT as a native protocol. This enables developers to write Django consumers that subscribe and publish to MQTT topics while maintaining full access to the Django ORM, Channel Layers, and testing suites.

This skill is particularly valuable when building complex IoT backbones or home automation systems where data persistence and real-time coordination are required. By integrating this into your Openclaw Skills workflow, you can create intelligent agents that interact directly with hardware devices, sensors, and actuators through a standard Django-based architecture.

mqttasgi Use Cases

  • Creating home automation hubs that trigger Django ORM events based on motion sensor data.
  • Building AI-powered IoT responders that route sensor data through LLMs to determine automated actions.
  • Monitoring energy consumption with real-time threshold alerts and database logging.
  • Coordinating multi-device environments using isolated workers for different physical zones or rooms.
  • Managing schedule-based industrial automation, such as garden irrigation, synchronized with database-backed logic.

How mqttasgi Works

  1. The mqttasgi server initializes and establishes a persistent connection to an MQTT broker (like Mosquitto) using specified host and port configurations.
  2. When an MQTT message arrives on a subscribed topic, the server translates the raw packet into an ASGI-compatible event.
  3. The event is routed through the Django ProtocolTypeRouter to the designated MqttConsumer.
  4. Inside the consumer, developers can use asynchronous methods to interact with the database, send messages to other channel groups, or publish new MQTT messages.
  5. The server manages the lifecycle of connections, supporting clean sessions, SSL/TLS security, and automatic reconnection retries.

mqttasgi Setup

Install the package via pip:

pip install mqttasgi

Configure your asgi.py to route the mqtt protocol:

from channels.routing import ProtocolTypeRouter
from my_application.consumers import MyMqttConsumer

application = ProtocolTypeRouter({
    'mqtt': MyMqttConsumer.as_asgi(),
})

Launch the protocol server from the command line:

mqttasgi -H localhost -p 1883 my_application.asgi:application

mqttasgi Data Schema & Taxonomy

The skill handles data through structured dictionary events within the ASGI scope. Below is the internal schema for MQTT messages:

Attribute Type Description
topic String The MQTT topic the message was received on or will be published to.
payload Bytes The raw message content.
qos Integer Quality of Service level (0, 1, or 2).
retain Boolean Whether the message should be retained by the broker (publish only).
type String Internal event type: mqtt.connect, mqtt.msg, mqtt.pub, or mqtt.sub.

mqttasgi Advanced Features

  • Multi-worker orchestration allowing a master consumer to dynamically spawn and kill dedicated workers for specific tasks.
  • Brokerless testing utilities via MqttComunicator, enabling unit tests for IoT logic without a running MQTT broker.
  • Robust environment variable support for all configuration parameters, simplifying Docker and Kubernetes deployments.
  • Support for both TCP and WebSockets transports to accommodate diverse networking environments.
  • Full compatibility with modern Python versions and Django Channels 3.x/4.x, ensuring longevity for your Openclaw Skills projects.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*