You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
402 B
Python

import paho.mqtt.publish as publish
import os
import time
import socket
HOSTNAME = socket.gethostname()
HOST = os.environ.get('MQTT_HOST', 'localhost')
print('Connecting to %s' %HOST)
topic = "/gsi/test/multiple"
i = 0
while True:
print('%s pushing msg %s' %(HOSTNAME, i))
publish.single(topic=topic, payload='%s says %s' %(HOSTNAME, i), qos=1, hostname=HOST)
i += 1
time.sleep(2)