Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # quickly publishes to a topic
- import os
- import time
- import sys
- import mosquitto
- print "Trying to connect to MQTT server."
- def on_connect(mosq, obj, rc):
- print("rc: "+str(rc))
- def on_publish(mosq, obj, mid):
- print("mid: "+str(mid))
- mqttc = mosquitto.Mosquitto()
- mqttc.on_connect = on_connect
- mqttc.on_publish = on_publish
- mqttc.connect("mqtt.localdomain", 1883, 60)
- print "Publishing"
- mqttc.publish("/status/lounge/xbmc", "play", retain=False)
- print "Done."
- mqttc.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement