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