Browse Source

Upgrade to Paho Python
closes #3

Jan-Piet Mens 10 years ago
parent
commit
ca9b60243c
2 changed files with 4 additions and 4 deletions
  1. 1 1
      README.md
  2. 3 3
      mqtt2graphite.py

+ 1 - 1
README.md

@@ -12,7 +12,7 @@ numeric, these are then sent off to Carbon (see example below)
 
 ## Requirements
 
-* [mosquitto.py](http://mosquitto.org/documentation/python/)
+* [Paho Python MQTT](https://pypi.python.org/pypi/paho-mqtt)
 * A running Carbon/Graphite server with UDP-enabled reception
 * Access to an MQTT broker. (I use [Mosquitto](http://mosquitto.org/))
 

+ 3 - 3
mqtt2graphite.py

@@ -3,7 +3,7 @@
 __author__ = "Jan-Piet Mens"
 __copyright__ = "Copyright (C) 2013 by Jan-Piet Mens"
 
-import mosquitto
+import paho.mqtt.client as paho
 import ssl
 import os, sys
 import logging
@@ -67,7 +67,7 @@ def on_message(mosq, userdata, msg):
     # Find out how to handle the topic in this message: slurp through
     # our map 
     for t in map:
-        if mosquitto.topic_matches_sub(t, msg.topic):
+        if paho.topic_matches_sub(t, msg.topic):
             # print "%s matches MAP(%s) => %s" % (msg.topic, t, map[t])
 
             # Must we rename the received msg topic into a different
@@ -155,7 +155,7 @@ if __name__ == '__main__':
         'carbon_port'   : CARBON_PORT,
         'map'       : map,
     }
-    mqttc = mosquitto.Mosquitto(client_id, clean_session=True, userdata=userdata)
+    mqttc = paho.Client(client_id, clean_session=True, userdata=userdata)
     mqttc.on_message = on_message
     mqttc.on_connect = on_connect
     mqttc.on_disconnect = on_disconnect