PyQTTier
A Python MQTT client library providing a clean, type-safe wrapper around paho-mqtt with support for MQTT 5.0 features.
Features
- MQTT 5.0 Support - Full support for MQTT 5.0 protocol features including message properties, correlation data, and response topics
- Type Safety - Strongly typed with mypy-checked type hints for reliability
- Multiple Transports - Supports TCP, WebSocket, and Unix socket connections
- Mock Implementation - Built-in
MockConnectionfor easy testing without a broker - Python 3.7+ - Compatible with Python 3.7 through 3.12
Installation
pip install pyqttier
Quick Start
Basic Usage
from pyqttier.connection import Mqtt5Connection
from pyqttier.transport import MqttTransport, MqttTransportType
from pyqttier.message import Message
# Connect to broker
transport = MqttTransport(
transport_type=MqttTransportType.TCP,
host="localhost",
port=1883,
)
conn = Mqtt5Connection(transport=transport, client_id="my-client")
# Subscribe to a topic
def on_message(msg: Message):
print(f"Received: {msg.payload.decode()}")
conn.subscribe("sensors/temperature", callback=on_message)
# Publish a message
msg = Message(topic="sensors/temperature", payload=b"23.5", qos=1)
conn.publish(msg)
Testing with MockConnection
from pyqttier.mock import MockConnection
from pyqttier.message import Message
# Create mock connection for testing
conn = MockConnection()
# Publish and verify
result = conn.publish(Message(topic="test", payload=b"data", qos=1))
assert result.done()
assert len(conn.published_messages) == 1
assert conn.published_messages[0].topic == "test"
Examples
See the examples/ directory for more detailed usage examples:
usage_example.py- Real broker connections, wildcards, request-response patternsmock_example.py- Testing with MockConnection
Development
# Install project
uv pip install -e .
# Type checking
uv run mypy --check-untyped-defs ./src/
# Unit tests
uv run pytest
License
MIT License.
See LICENSE file for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyqttier-0.2.9.tar.gz
(69.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pyqttier-0.2.9-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file pyqttier-0.2.9.tar.gz.
File metadata
- Download URL: pyqttier-0.2.9.tar.gz
- Upload date:
- Size: 69.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01525ae688dd1ae00e0ab627767570775923ac6d82c4f3f6cb6491123b0820e0
|
|
| MD5 |
c19a17ee7ee02ffb98268cd1010010d8
|
|
| BLAKE2b-256 |
aefe6c247368a1176ebaafae323eff9ac7d15ec5f7a0459f4a46a75de685422d
|
File details
Details for the file pyqttier-0.2.9-py3-none-any.whl.
File metadata
- Download URL: pyqttier-0.2.9-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a17acabd54d6c3f5f58a4aa7239680c4ef79105f28576e65f7227cdf818e4f8c
|
|
| MD5 |
72ed6760ba34f467c45498a1b2cff564
|
|
| BLAKE2b-256 |
67b6d7abc961b0946e785e517b7759d00f46c911d984a93b2136280b39bf4601
|