Skip to content

laidbackcoder/EssentialMQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EssentialMQTT

An easy to use Python module with just the essentials for working with MQTT1.

💻 Basic Usage

Setup & Connect to the MQTT Broker

from essentialmqtt import mqtt_client

client_id = 'test_client_1'
broker = '127.0.0.1'
topic = 'essentialmqtt/test/value1'


mqtt = mqtt_client(client_id, broker)
mqtt.connect()

...

Subscribe to a Topic

# Define a callback to be executed upon topic value change
def on_message(msg):
    # e.g. Print any topic value changes to the console
    print("Received: {} ({})".format(msg.payload.decode(), msg.topic))

mqtt.subscribe_to_topic(topic, on_message)

...

Publish to a Topic

mqtt.publish_message(topic, "topic value")

...

Disconnect from the MQTT Broker

...

mqtt.disconnect()

See Examples for more information

👍 Additional Credits

This project is built upon the Paho MQTT Python Module from eclipse.

Footnotes

  1. https://mqtt.org/

About

An Easy to use MQTT module for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages