From 998ad12e61be70220838f6d5e0a5a694876aff3f Mon Sep 17 00:00:00 2001 From: Marcus Brown Date: Sun, 20 Oct 2024 18:50:11 +1100 Subject: [PATCH] Fix syntax error and redundant connection call in MQTT client - Removed duplicate `async` keyword from `on_connect` method. - Removed redundant `await client.connect()` to avoid double connection attempt. --- dayglo_detector/dayglo_detector.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dayglo_detector/dayglo_detector.py b/dayglo_detector/dayglo_detector.py index 3295e8d..788b618 100644 --- a/dayglo_detector/dayglo_detector.py +++ b/dayglo_detector/dayglo_detector.py @@ -33,7 +33,7 @@ initial_snapshot_processed = False connected_once = False class DaygloDetectorMQTTClient(MQTTClient): - async async def on_connect(self, client, flags, rc, properties): + async def on_connect(self, client, flags, rc, properties): global connected_once if rc == 0 and not connected_once: print("Connected successfully to MQTT broker") @@ -133,7 +133,6 @@ async def main(): client = DaygloDetectorMQTTClient("dayglo_detector") client.set_auth_credentials(MQTT_USERNAME, MQTT_PASSWORD) - await client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60) await client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60) await asyncio.get_event_loop().create_future()