#! /usr/bin/python3 # =================================================================== # MQTT Publish # ------------------------------------------------------------------- # Python Client Documentation # www.eclipse.org/paho/index.php?page=clients/python/docs/index.php # =================================================================== import paho.mqtt.publish as publish import time broker = '192.168.1.77' topic = 'sensors/sensor1' # ---- main print() print(f"broker: {broker}") print(f"topic : {topic}") print() print("Publishing status ...") publish.single(topic, 'abc', qos=0, hostname=broker) print("Sleep ...") time.sleep(2) print("Publishing status ...") publish.single(topic, 'xyz', qos=0, hostname=broker)