diff --git a/examples/mqtt.py b/examples/mqtt.py index 0c044bd..bde8a5d 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -13,6 +13,7 @@ import time from PIL import Image,ImageDraw,ImageFont import traceback from paho.mqtt import client as mqtt_client +import paho.mqtt.client as paho logging.basicConfig(level=logging.DEBUG) @@ -37,15 +38,15 @@ broker = "192.168.99.224" port = 8883 topic = "openWB/evu/W" username = "mqtt-user" -password = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP" +pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP" client_id = "solarmonitor" -client = mqtt_client.Client(client_id) -client.username_pw_set(username, password) +client = mqtt_client.Client(client_id, protocol=paho.MQTTv31) +client.username_pw_set(username, password=pw) client.on_connect = on_connect client.on_message = on_message -client.connect(broker, port) +client.connect(broker, port=port) client.loop_start() #start the loop