Skip to main content

Typed MQTT client and topic/payload model for ISA-95-ish messaging.

Project description

FranzMQ

FranzMQ is a flexible, structured MQTT communication library designed to streamline MQTT messaging for internal and external communication in edge and cloud applications. It builds on top of the paho-mqtt client and introduces a typed, hierarchical topic and payload system based on the ISA-95 model.

Features

  • 🧠 Typed Payloads using Python dataclasses
  • 🧵 Priority-based concurrent callbacks for message handling
  • 📦 ISA-95 topic modeling for enterprise-ready messaging structures
  • 🔒 TLS support with environment-based auto-configuration
  • 🧪 Validation-ready versioning and context-driven payload classes
  • 📊 MQTT-based logging with seamless integration

Installation

Install using pip:

pip install franzmq

Quick Start

from franzmq.client import Client
from franzmq.payload import Metric
from franzmq.topic import Topic

client = Client.autocreate_and_connect(client_id="my-client")

topic = Topic(payload_type=Metric, context=("sensor", "temperature"))
metric = Metric(value=22.5)

client.publish(topic, metric)

Typed Payloads

All messages use structured dataclasses (e.g., Metric, Log, ServiceDetails, etc.) that encode/decode automatically to/from JSON.

Logging over MQTT

Enable logging by calling:

client.configure_mqtt_logger(level=logging.INFO)

Auto Configuration via Environment Variables

Uses python-decouple for environment configuration.

Required Variables

  • MQTT_IP
  • MQTT_USERNAME
  • MQTT_PASSWORD
  • MQTT_PORT (optional)
  • USE_MQTTS
  • CA_CERT_FILE (optional)
  • TLS_CERT_FILE (optional)
  • TLS_KEY_FILE (optional)

Callback System

Subscribe to topics and register priority-based callbacks:

client.subscribe(topic, qos=1, callback=my_callback, priority=10)

Callbacks with the same priority are executed concurrently; higher-priority callbacks run first.

Payload Types

Includes predefined payloads such as:

  • Metric
  • Log
  • And many more are easily self-definable...

Testing ISA-95 Topics

from franzmq.topic import Isa95Topic, Topic, Isa95Fields

basic_topic = Topic(payload_type=Metric, context=("sensor", "temperature"))
isa95_fields = Isa95Fields(enterprise="ent1", site="s1", area="a1", production_line="pl1", work_cell="wc1", origin_id="origin1")
isa95_topic = Isa95Topic.from_topic(basic_topic, isa95_fields)

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

franzmq-0.4.0b3.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

franzmq-0.4.0b3-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file franzmq-0.4.0b3.tar.gz.

File metadata

  • Download URL: franzmq-0.4.0b3.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for franzmq-0.4.0b3.tar.gz
Algorithm Hash digest
SHA256 f6bb3b6eeaebbd7f4a25a495135561f59b51f85b995d2bdee5144ccfdf309a87
MD5 33c70038c3cc7740f09dd7347d9bea47
BLAKE2b-256 4697b677a47ee862049ffa25e99ef7a8867e1ec573c91b64121f2d138429017e

See more details on using hashes here.

Provenance

The following attestation bundles were made for franzmq-0.4.0b3.tar.gz:

Publisher: publish.yml on alpamayo-solutions/franzmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file franzmq-0.4.0b3-py3-none-any.whl.

File metadata

  • Download URL: franzmq-0.4.0b3-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for franzmq-0.4.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 919edf09197d39e3b6f886a27beac45d804003e6af4b264c92037e1108841f6f
MD5 f4767b69629b19de4ea1b90a3872a526
BLAKE2b-256 e038d96db8db02c8e358af5b367a1debe311496eeb35555c52ea67a4848f75e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for franzmq-0.4.0b3-py3-none-any.whl:

Publisher: publish.yml on alpamayo-solutions/franzmq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page