diff --git a/backend/app/database/myp.db b/backend/app/database/myp.db index a747a80e..7a498da4 100644 Binary files a/backend/app/database/myp.db and b/backend/app/database/myp.db differ diff --git a/backend/app/database/myp.db-wal b/backend/app/database/myp.db-wal index 1f4f98d6..e69de29b 100644 Binary files a/backend/app/database/myp.db-wal and b/backend/app/database/myp.db-wal differ diff --git a/backend/app/database/myp.db.backup_20250529_231800 b/backend/app/database/myp.db.backup_20250529_231800 new file mode 100644 index 00000000..46a0c1b1 Binary files /dev/null and b/backend/app/database/myp.db.backup_20250529_231800 differ diff --git a/backend/app/utils/printer_monitor.py b/backend/app/utils/printer_monitor.py index 7b6b33b3..52dcb007 100644 --- a/backend/app/utils/printer_monitor.py +++ b/backend/app/utils/printer_monitor.py @@ -300,7 +300,10 @@ class PrinterMonitor: def _check_single_printer_status(self, printer: Printer, timeout: int = 7) -> Dict: """ - Überprüft den Status eines einzelnen Druckers. + Überprüft den Status eines einzelnen Druckers basierend auf der Steckdosen-Logik: + - Steckdose erreichbar aber AUS = Drucker ONLINE (bereit zum Drucken) + - Steckdose erreichbar und AN = Drucker PRINTING (druckt gerade) + - Steckdose nicht erreichbar = Drucker OFFLINE (kritischer Fehler) Args: printer: Printer-Objekt aus der Datenbank @@ -341,25 +344,44 @@ class PrinterMonitor: status_info["outlet_reachable"] = outlet_reachable status_info["outlet_state"] = outlet_state - if outlet_reachable and outlet_state == "on": - status_info["status"] = "online" - status_info["active"] = True - elif outlet_reachable and outlet_state == "off": - status_info["status"] = "standby" - status_info["active"] = False + # 🎯 KORREKTE LOGIK: Steckdose erreichbar = Drucker funktionsfähig + if outlet_reachable: + if outlet_state == "off": + # Steckdose aus = Drucker ONLINE (bereit zum Drucken) + status_info["status"] = "online" + status_info["active"] = True + monitor_logger.debug(f"✅ {printer.name}: ONLINE (Steckdose aus - bereit zum Drucken)") + elif outlet_state == "on": + # Steckdose an = Drucker PRINTING (druckt gerade) + status_info["status"] = "printing" + status_info["active"] = True + monitor_logger.debug(f"🖨️ {printer.name}: PRINTING (Steckdose an - druckt gerade)") + else: + # Unbekannter Steckdosen-Status + status_info["status"] = "error" + status_info["active"] = False + monitor_logger.warning(f"⚠️ {printer.name}: Unbekannter Steckdosen-Status '{outlet_state}'") else: + # Steckdose nicht erreichbar = kritischer Fehler status_info["status"] = "offline" status_info["active"] = False + monitor_logger.warning(f"❌ {printer.name}: OFFLINE (Steckdose nicht erreichbar)") else: + # Ping fehlgeschlagen = Netzwerkproblem status_info["status"] = "unreachable" status_info["active"] = False + monitor_logger.warning(f"🔌 {printer.name}: UNREACHABLE (Ping fehlgeschlagen)") else: + # Keine Steckdosen-IP konfiguriert status_info["status"] = "unconfigured" status_info["active"] = False + monitor_logger.info(f"⚙️ {printer.name}: UNCONFIGURED (keine Steckdosen-IP)") except Exception as e: monitor_logger.error(f"❌ Fehler bei Status-Check für {printer.name}: {str(e)}") status_info["error"] = str(e) + status_info["status"] = "error" + status_info["active"] = False return status_info