From 8f6d24b6393b109b2c77a71bbad731f5bab2844f Mon Sep 17 00:00:00 2001 From: Vasilis Koulis Date: Sat, 30 Mar 2024 13:46:31 +0200 Subject: [PATCH] Fix paho-mqtt new versions --- alarmcode/notifier.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/alarmcode/notifier.py b/alarmcode/notifier.py index ecf1c91..2208c64 100644 --- a/alarmcode/notifier.py +++ b/alarmcode/notifier.py @@ -119,7 +119,10 @@ def setupMQTT(self): # self.mqttclient = mqtt.Client("", True, None, mqtt.MQTTv311) if not hasattr(self, 'mqttclient'): - self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False) + if hasattr(mqtt, "CallbackAPIVersion"): + self.mqttclient = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) + else: + self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False) self.mqttclient.disconnect() self.mqttclient.loop_stop(force=False)