🎉 Aktualisierung der Fehlerprotokollierung und Verbesserung der Dokumentation für Backend-Operationen 📝
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1,59 @@
|
||||
|
||||
# HTTP 500 Fehler beim PrinterMonitor - Behebung
|
||||
|
||||
## 🔧 Problem
|
||||
|
||||
Der PrinterMonitor erhielt einen HTTP 500 Fehler beim Aufruf von `/api/printers/status`:
|
||||
|
||||
```
|
||||
Fehler beim Abrufen des Drucker-Status: Error: HTTP 500:INTERNAL SERVER ERROR
|
||||
at PrinterMonitor.updatePrinterStatus (printer_monitor.min.js:12:214)
|
||||
```
|
||||
|
||||
## 🔍 Ursache
|
||||
|
||||
In der `api_get_printer_status` Funktion in `app.py` (Zeile ~962) wurde versucht, eine nicht existierende Funktion zu importieren:
|
||||
|
||||
```python
|
||||
# FALSCH:
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
```
|
||||
|
||||
Dies führte zu einem ImportError, da `get_tapo_controller` als Funktion nicht direkt exportiert wird.
|
||||
|
||||
## ✅ Lösung
|
||||
|
||||
Der Import wurde korrigiert zu:
|
||||
|
||||
```python
|
||||
# RICHTIG:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
```
|
||||
|
||||
### Warum funktioniert das?
|
||||
|
||||
In `utils/hardware_integration.py` (Zeile 716) wird `tapo_controller` bereits als globale Instanz erstellt und exportiert:
|
||||
|
||||
```python
|
||||
# Am Ende von hardware_integration.py:
|
||||
tapo_controller = get_tapo_controller()
|
||||
```
|
||||
|
||||
## 📝 Wichtige Punkte
|
||||
|
||||
1. **Import-Syntax**: Beim Import von Instanzen direkt den Variablennamen verwenden
|
||||
2. **Fehlerbehandlung**: Der Code hat bereits robuste Fehlerbehandlung für den Fall, dass der Tapo-Controller nicht verfügbar ist
|
||||
3. **Neustart erforderlich**: Nach der Änderung muss der Server neu gestartet werden
|
||||
|
||||
## 🚀 Nächste Schritte
|
||||
|
||||
1. Server neu starten: `python app.py`
|
||||
2. Testen: Öffnen Sie die Drucker-Seite und prüfen Sie die Browser-Konsole
|
||||
3. Der PrinterMonitor sollte nun erfolgreich den Status abrufen
|
||||
|
||||
## 🎯 Ergebnis
|
||||
|
||||
Nach dem Neustart funktioniert der `/api/printers/status` Endpoint korrekt und liefert:
|
||||
- Drucker-Basis-Informationen
|
||||
- Steckdosen-Status (wenn konfiguriert)
|
||||
- Fehlerbehandlung für nicht erreichbare Steckdosen
|
@ -1 +1,190 @@
|
||||
|
||||
# Tapo-Integration Implementation - MYP System
|
||||
|
||||
## 🎯 Implementierte Funktionalitäten
|
||||
|
||||
### 1. **TapoStatusManager** - Zentrale Status-Verwaltung
|
||||
|
||||
Der neue `TapoStatusManager` in `backend/utils/tapo_status_manager.py` bietet:
|
||||
|
||||
#### **Die 3 Status-Zustände:**
|
||||
- **`on`** - Steckdose eingeschaltet (grün)
|
||||
- **`off`** - Steckdose ausgeschaltet (grau)
|
||||
- **`unreachable`** - Steckdose nicht erreichbar (rot)
|
||||
|
||||
#### **Hauptfunktionen:**
|
||||
```python
|
||||
# Status eines Druckers abrufen
|
||||
status = tapo_status_manager.get_printer_status(printer_id)
|
||||
|
||||
# Status aller Drucker abrufen
|
||||
all_status = tapo_status_manager.get_all_printer_status()
|
||||
|
||||
# Steckdose steuern
|
||||
success, msg = tapo_status_manager.control_plug(printer_id, "on"|"off")
|
||||
|
||||
# Automatische Job-Steuerung
|
||||
tapo_status_manager.check_and_control_for_jobs()
|
||||
```
|
||||
|
||||
### 2. **Automatische Steckdosen-Steuerung**
|
||||
|
||||
Die automatische Steuerung wurde in den `JobScheduler` integriert:
|
||||
|
||||
- **Job startet**: Steckdose wird automatisch eingeschaltet
|
||||
- **Job endet**: Steckdose wird automatisch ausgeschaltet
|
||||
- **Fehlerbehandlung**: Jobs werden trotzdem gestartet/beendet, auch wenn Steckdose nicht erreichbar
|
||||
|
||||
### 3. **API-Endpunkte**
|
||||
|
||||
#### **Drucker-Status** (`/api/printers/status`)
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"printers": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "3D-Drucker 1 - Halle A",
|
||||
"plug_status": "on|off|unreachable",
|
||||
"plug_reachable": true|false,
|
||||
"has_plug": true,
|
||||
"status_display": {
|
||||
"text": "An|Aus|Nicht erreichbar",
|
||||
"color": "green|gray|red",
|
||||
"icon": "power|power-off|exclamation-triangle"
|
||||
},
|
||||
"current_job": {...},
|
||||
"next_job": {...}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 4. **Kalender-Integration für Admins**
|
||||
|
||||
Die Kalender-Events enthalten für Admins erweiterte Informationen:
|
||||
|
||||
```javascript
|
||||
event = {
|
||||
"id": "job_123",
|
||||
"title": "Druckauftrag XYZ",
|
||||
"extendedProps": {
|
||||
"plugStatus": "on|off|unreachable",
|
||||
"plugReachable": true|false,
|
||||
"statusDisplay": {
|
||||
"text": "An",
|
||||
"color": "green",
|
||||
"icon": "power"
|
||||
}
|
||||
},
|
||||
"tooltip": "Job: XYZ\nDrucker: 1\nSteckdose: An\n✓ Steckdose erreichbar"
|
||||
}
|
||||
```
|
||||
|
||||
### 5. **Die 6 Standard-Drucker**
|
||||
|
||||
Die folgenden 6 Drucker sind standardmäßig konfiguriert:
|
||||
|
||||
1. **3D-Drucker 1 - Halle A** (Prusa MK3S+)
|
||||
- IP: 192.168.1.101
|
||||
- Steckdose: 192.168.1.201
|
||||
|
||||
2. **3D-Drucker 2 - Halle A** (Prusa MK3S+)
|
||||
- IP: 192.168.1.102
|
||||
- Steckdose: 192.168.1.202
|
||||
|
||||
3. **3D-Drucker 3 - Halle B** (Ultimaker S5)
|
||||
- IP: 192.168.1.103
|
||||
- Steckdose: 192.168.1.203
|
||||
|
||||
4. **3D-Drucker 4 - Halle B** (Ultimaker S5)
|
||||
- IP: 192.168.1.104
|
||||
- Steckdose: 192.168.1.204
|
||||
|
||||
5. **3D-Drucker 5 - Labor** (Formlabs Form 3)
|
||||
- IP: 192.168.1.105
|
||||
- Steckdose: 192.168.1.205
|
||||
|
||||
6. **3D-Drucker 6 - Werkstatt** (Markforged X7)
|
||||
- IP: 192.168.1.106
|
||||
- Steckdose: 192.168.1.206
|
||||
|
||||
## 🧪 Test-Skripte
|
||||
|
||||
### **test_printer_setup.py**
|
||||
Interaktives Skript zum Einrichten und Testen der Drucker:
|
||||
```bash
|
||||
cd backend
|
||||
python scripts/test_printer_setup.py
|
||||
```
|
||||
|
||||
### **test_tapo_integration.py**
|
||||
Umfassende Pytest-Suite für alle Funktionalitäten:
|
||||
```bash
|
||||
cd backend
|
||||
python -m pytest tests/test_tapo_integration.py -v
|
||||
```
|
||||
|
||||
## 🔧 Konfiguration
|
||||
|
||||
### **Umgebungsvariablen**
|
||||
```bash
|
||||
# In .env oder als Systemvariablen
|
||||
TAPO_USERNAME=admin@email.com
|
||||
TAPO_PASSWORD=secure_password
|
||||
```
|
||||
|
||||
### **Drucker-Konfiguration**
|
||||
Jeder Drucker benötigt:
|
||||
- `plug_ip` - IP-Adresse der Tapo-Steckdose
|
||||
- `plug_username` - Tapo-Account-Benutzername
|
||||
- `plug_password` - Tapo-Account-Passwort
|
||||
|
||||
## 📊 Status-Darstellung
|
||||
|
||||
### **UI-Komponenten**
|
||||
- **Drucker-Übersicht**: Zeigt alle 6 Drucker mit aktuellem Status
|
||||
- **Kalender**: Erweiterte Tooltips mit Steckdosen-Status für Admins
|
||||
- **Admin-Dashboard**: Übersicht über alle Steckdosen-Stati
|
||||
|
||||
### **Status-Farben**
|
||||
- 🟢 **Grün**: Steckdose eingeschaltet
|
||||
- ⚪ **Grau**: Steckdose ausgeschaltet
|
||||
- 🔴 **Rot**: Steckdose nicht erreichbar
|
||||
|
||||
## 🚀 Verwendung
|
||||
|
||||
### **Manueller Test der Steckdosen**
|
||||
1. Als Admin einloggen
|
||||
2. Zu "Tapo-Steuerung" navigieren
|
||||
3. Drucker auswählen und "Ein/Aus" klicken
|
||||
|
||||
### **Automatische Steuerung**
|
||||
1. Job erstellen mit Start- und Endzeit
|
||||
2. System schaltet Steckdose automatisch ein/aus
|
||||
3. Status wird im Kalender angezeigt
|
||||
|
||||
## 🔒 Sicherheit
|
||||
|
||||
- Nur Admins können Steckdosen manuell steuern
|
||||
- Passwörter werden verschlüsselt gespeichert
|
||||
- Fehlerhafte Steckdosen blockieren keine Jobs
|
||||
|
||||
## 📝 Logging
|
||||
|
||||
Alle Steckdosen-Operationen werden geloggt:
|
||||
- In `PlugStatusLog` Tabelle
|
||||
- In `logs/tapo_controller/*.log`
|
||||
- In `logs/tapo_status_manager/*.log`
|
||||
|
||||
## ⚠️ Fehlerbehandlung
|
||||
|
||||
- **Steckdose nicht erreichbar**: Job läuft trotzdem
|
||||
- **Falsches Passwort**: Fehlermeldung in UI
|
||||
- **Netzwerkfehler**: Automatischer Retry nach 30 Sekunden
|
||||
|
||||
## 🎯 Nächste Schritte
|
||||
|
||||
1. **Dashboard-Widget** für Echtzeit-Status
|
||||
2. **Energieverbrauch-Tracking** (wenn von Tapo unterstützt)
|
||||
3. **Automatische Fehler-Benachrichtigungen** per E-Mail
|
||||
4. **Zeitbasierte Steckdosen-Profile** (z.B. Nachtabschaltung)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user