Fix indentation errors in on_connect function to prevent runtime issues
- Corrected inconsistent indentation to match the expected Python format. - Ensured proper alignment of the `on_connect` function code block.
This commit is contained in:
@@ -31,14 +31,14 @@ initial_snapshot_processed = False
|
|||||||
|
|
||||||
def on_connect(client, userdata, flags, reasonCode, properties=None):
|
def on_connect(client, userdata, flags, reasonCode, properties=None):
|
||||||
try:
|
try:
|
||||||
if reasonCode == 0:
|
if reasonCode == 0:
|
||||||
print("Connected successfully to MQTT broker")
|
print("Connected successfully to MQTT broker")
|
||||||
client.subscribe(MQTT_SNAPSHOT_TOPIC, qos=1)
|
client.subscribe(MQTT_SNAPSHOT_TOPIC, qos=1)
|
||||||
print(f"Subscribed to topic: {MQTT_SNAPSHOT_TOPIC}")
|
print(f"Subscribed to topic: {MQTT_SNAPSHOT_TOPIC}")
|
||||||
publish_discovery_configurations()
|
publish_discovery_configurations()
|
||||||
# Publish initial rating of 0
|
# Publish initial rating of 0
|
||||||
publish_rating(0)
|
publish_rating(0)
|
||||||
else:
|
else:
|
||||||
print(f"Failed to connect, return code {reasonCode}")
|
print(f"Failed to connect, return code {reasonCode}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Caught exception in on_connect: {e}")
|
print(f"Caught exception in on_connect: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user