Skip to content

Commit

Permalink
fix: Upgrade to support paho-mqtt>=2.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjw committed Jun 28, 2024
1 parent 0faa129 commit 16e4b1f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions glowprom/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@
import paho.mqtt.client as mqtt


def on_connect(topic, client, userdata, flags, rc):
print("Connected with result code "+str(rc))
def on_connect(topic: str,
client: mqtt.Client,
userdata,
flags,
reason_code,
properties):
if reason_code > 0:
sys.stderr.write(f"Failed to connect to mqtt: {reason_code}")

print("Successfully connected to mqtt broker.")
client.subscribe(topic)


Expand All @@ -41,7 +48,7 @@ def safe_on_message(client, userdata, msg):


def connect(args, on_message, retry=True):
client = mqtt.Client()
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
client.on_connect = \
functools.partial(on_connect,
args.topic if args.cloud else "glow/+/+/+")
Expand Down

0 comments on commit 16e4b1f

Please sign in to comment.