MQTT status fix
This commit is contained in:
@@ -30,7 +30,6 @@ def print_label(image, printer=PRINTER_DEVICE, model=PRINTER_MODEL, label=LABEL_
|
||||
"""Print the label directly using brother_ql module"""
|
||||
import os
|
||||
|
||||
try:
|
||||
# Check if printer device exists
|
||||
if not os.path.exists(printer):
|
||||
raise Exception(f"Printer device {printer} not found. Make sure the printer is powered on and connected via USB.")
|
||||
@@ -46,8 +45,6 @@ def print_label(image, printer=PRINTER_DEVICE, model=PRINTER_MODEL, label=LABEL_
|
||||
status = send(instructions=instructions, printer_identifier=f"file://{printer}", backend_identifier='linux_kernel', blocking=True)
|
||||
|
||||
return status
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print(f"Connected to MQTT broker at {MQTT_HOST}:{MQTT_PORT} with result code {rc}")
|
||||
@@ -150,12 +147,12 @@ def on_message(client, userdata, msg):
|
||||
print(error_msg)
|
||||
error_details = {"status": "error", "job_id": job_id, "error": error_msg, "topic": msg.topic}
|
||||
client.publish(MQTT_TOPIC_PUB_STATUS, json.dumps(error_details))
|
||||
send_webhook("parse_error", error_details)
|
||||
except Exception as e:
|
||||
error_msg = f"Error processing message: {str(e)}"
|
||||
print(error_msg)
|
||||
error_details = {"status": "error", "job_id": job_id, "error": error_msg, "original_payload": raw_payload}
|
||||
client.publish(MQTT_TOPIC_PUB_STATUS, json.dumps(error_details))
|
||||
send_webhook("processing_error", error_details)
|
||||
|
||||
def heartbeat(client):
|
||||
while True:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user