An easy to use Python module with just the essentials for working with MQTT1.
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()
...
# 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)
...
mqtt.publish_message(topic, "topic value")
...
...
mqtt.disconnect()
See Examples for more information
This project is built upon the Paho MQTT Python Module from eclipse.