📚 Improved documentation for TAPO issue resolution in backend/TAPO_PROBLEMBEHEBUNG.md

This commit is contained in:
2025-06-18 06:53:06 +02:00
parent a44b1da2e6
commit f06c882c5a
9 changed files with 1205 additions and 91 deletions

View File

@@ -196,7 +196,7 @@ class TapoStatusManager:
def _check_tapo_status(self, printer: Printer) -> Dict[str, any]:
"""
Prüft den Tapo-Steckdosen-Status
Prüft den Tapo-Steckdosen-Status mit erweiterten Fallback-Mechanismen
Args:
printer: Printer-Objekt
@@ -209,6 +209,7 @@ class TapoStatusManager:
from utils.hardware_integration import tapo_controller
if not tapo_controller:
logger.warning(f"Tapo-Controller nicht verfügbar für {printer.name}")
return {
"plug_status": self.STATUS_UNREACHABLE,
"plug_reachable": False,
@@ -217,38 +218,69 @@ class TapoStatusManager:
"error": "Tapo-Controller nicht verfügbar"
}
# Status abrufen
# Status abrufen mit Debug-Informationen
logger.debug(f"Prüfe Tapo-Status für {printer.name} ({printer.plug_ip})")
reachable, plug_status = tapo_controller.check_outlet_status(
printer.plug_ip,
printer_id=printer.id
printer_id=printer.id,
debug=False # Weniger Debug-Output für bessere Performance
)
if reachable:
# Erfolgreiche Verbindung
logger.debug(f"✅ Tapo-Steckdose {printer.plug_ip} erreichbar - Status: {plug_status}")
# Status normalisieren
if plug_status in ["on", "true", "1", True]:
normalized_status = self.STATUS_ON
power_status = "on"
elif plug_status in ["off", "false", "0", False]:
normalized_status = self.STATUS_OFF
power_status = "off"
else:
# Unbekannter Status, aber erreichbar
normalized_status = self.STATUS_UNREACHABLE
power_status = "unknown"
logger.warning(f"Unbekannter Tapo-Status '{plug_status}' für {printer.name}")
return {
"plug_status": self.STATUS_ON if plug_status == "on" else self.STATUS_OFF,
"plug_status": normalized_status,
"plug_reachable": True,
"power_status": plug_status,
"can_control": True
"power_status": power_status,
"can_control": True,
"last_check": datetime.now().isoformat()
}
else:
# Steckdose nicht erreichbar
logger.warning(f"⚠️ Tapo-Steckdose {printer.plug_ip} nicht erreichbar für {printer.name}")
return {
"plug_status": self.STATUS_UNREACHABLE,
"plug_reachable": False,
"power_status": None,
"can_control": False,
"error": "Steckdose nicht erreichbar"
"error": "Steckdose nicht erreichbar",
"last_check": datetime.now().isoformat()
}
except Exception as e:
logger.error(f"Fehler beim Prüfen des Tapo-Status für {printer.name}: {str(e)}")
except ImportError as e:
logger.error(f"Import-Fehler beim Tapo-Controller für {printer.name}: {str(e)}")
return {
"plug_status": self.STATUS_UNREACHABLE,
"plug_reachable": False,
"power_status": None,
"can_control": False,
"error": str(e)
"error": f"Import-Fehler: {str(e)}",
"fallback_used": True
}
except Exception as e:
logger.error(f"Unerwarteter Fehler beim Prüfen des Tapo-Status für {printer.name}: {str(e)}")
return {
"plug_status": self.STATUS_UNREACHABLE,
"plug_reachable": False,
"power_status": None,
"can_control": False,
"error": str(e),
"last_check": datetime.now().isoformat()
}
def control_plug(self, printer_id: int, action: str) -> Tuple[bool, str]: