🔧 Fix: check_outlet_status Methode Parameter korrigiert

- printer_id Parameter als optional hinzugefügt für Legacy-Kompatibilität
- Return-Format auf tuple (reachable, status) geändert für bestehenden Code
- Korrekte Status-Mapping: device_on -> 'online'/'offline'
- Error-Handling mit spezifischen Status-Codes
- Debug-Logging erweitert mit printer_id Info

Fixes: check_outlet_status() got an unexpected keyword argument 'printer_id'

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-06-19 22:52:55 +02:00
parent 7f0d477985
commit e38b336c93

View File

@ -426,24 +426,22 @@ class DruckerSteuerung:
"""Wrapper für template_daten_sammeln (Backward-Compatibility)"""
return self.template_daten_sammeln()
def check_outlet_status(self, ip: str) -> Dict[str, Any]:
def check_outlet_status(self, ip: str, printer_id: Optional[int] = None) -> tuple:
"""
Prüft den Status einer Tapo-Steckdose.
Args:
ip: IP-Adresse der Steckdose
printer_id: Optional - ID des Druckers (für Legacy-Kompatibilität)
Returns:
Dict mit Status-Informationen
tuple: (reachable: bool, status: str) - Legacy-Format für Kompatibilität
"""
hardware_logger.debug(f"🔍 Prüfe Steckdosen-Status: {ip}")
hardware_logger.debug(f"🔍 Prüfe Steckdosen-Status: {ip}" + (f" (Drucker ID: {printer_id})" if printer_id else ""))
if not TAPO_AVAILABLE:
return {
'success': True,
'outlet_on': True,
'message': 'Simulation: Steckdose online'
}
# Legacy-Format: (reachable, status)
return (True, 'online')
try:
# Tapo P100/P110 Verbindung
@ -460,33 +458,18 @@ class DruckerSteuerung:
hardware_logger.debug(f"✅ Steckdose {ip}: {'EIN' if device_on else 'AUS'}")
return {
'success': True,
'outlet_on': device_on,
'message': f"Steckdose ist {'eingeschaltet' if device_on else 'ausgeschaltet'}"
}
# Legacy-Format: (reachable, status)
return (True, 'online' if device_on else 'offline')
else:
hardware_logger.warning(f"⚠️ Steckdose {ip} Error Code: {device_info['error_code']}")
return {
'success': False,
'outlet_on': False,
'message': f"Steckdose Fehler: {device_info['error_code']}"
}
return (False, 'error')
else:
hardware_logger.error(f"❌ Steckdose {ip}: Keine gültige Antwort")
return {
'success': False,
'outlet_on': False,
'message': 'Keine gültige Antwort von Steckdose'
}
return (False, 'unreachable')
except Exception as e:
hardware_logger.error(f"❌ Fehler beim Prüfen von Steckdose {ip}: {e}")
return {
'success': False,
'outlet_on': False,
'message': f'Verbindungsfehler: {str(e)}'
}
return (False, 'unreachable')
# ===== GLOBALE INSTANZ =====