diff --git a/dayglo_detector/dayglo_detector.py b/dayglo_detector/dayglo_detector.py index f6727a6..0be633d 100644 --- a/dayglo_detector/dayglo_detector.py +++ b/dayglo_detector/dayglo_detector.py @@ -29,7 +29,7 @@ UPPER_COLOR = np.array([35, 255, 255]) initial_snapshot_processed = False def on_connect(client, userdata, flags, reasonCode, properties=None): - if rc == 0: + if reasonCode == 0: print("Connected successfully to MQTT broker") client.subscribe(MQTT_SNAPSHOT_TOPIC, qos=1) print(f"Subscribed to topic: {MQTT_SNAPSHOT_TOPIC}") @@ -37,7 +37,7 @@ def on_connect(client, userdata, flags, reasonCode, properties=None): # Publish initial rating of 0 publish_rating(0) else: - print(f"Failed to connect, return code {rc}") + print(f"Failed to connect, return code {reasonCode}") def publish_discovery_configurations(): rating_config = { @@ -131,7 +131,7 @@ if len(sys.argv) > 1: print(f"File not found: {image_file}") # Set up MQTT client for normal operation -client = mqtt.Client(protocol=mqtt.MQTTv311) +client = mqtt.Client(protocol=mqtt.MQTTv5) client.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD) client.on_connect = on_connect client.on_message = on_message