🔧 Fix: DruckerSteuerung.check_outlet_status Methode hinzugefügt
- Fehlende check_outlet_status Methode zur DruckerSteuerung Klasse hinzugefügt - Vollständige Tapo-Steckdosen Status-Prüfung implementiert - Error-Handling für Verbindungsfehler und Device-Errors - Simulation-Mode Support für Entwicklung ohne Hardware - Debug-Logging für bessere Fehlerdiagnose Fixes AttributeError: 'DruckerSteuerung' object has no attribute 'check_outlet_status' 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -425,6 +425,68 @@ class DruckerSteuerung:
|
||||
def _template_daten_sammeln(self) -> Dict[str, Any]:
|
||||
"""Wrapper für template_daten_sammeln (Backward-Compatibility)"""
|
||||
return self.template_daten_sammeln()
|
||||
|
||||
def check_outlet_status(self, ip: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Prüft den Status einer Tapo-Steckdose.
|
||||
|
||||
Args:
|
||||
ip: IP-Adresse der Steckdose
|
||||
|
||||
Returns:
|
||||
Dict mit Status-Informationen
|
||||
"""
|
||||
hardware_logger.debug(f"🔍 Prüfe Steckdosen-Status: {ip}")
|
||||
|
||||
if not TAPO_AVAILABLE:
|
||||
return {
|
||||
'success': True,
|
||||
'outlet_on': True,
|
||||
'message': 'Simulation: Steckdose online'
|
||||
}
|
||||
|
||||
try:
|
||||
# Tapo P100/P110 Verbindung
|
||||
p100 = PyP100(ip, self.tapo_username, self.tapo_password)
|
||||
p100.handshake()
|
||||
p100.login()
|
||||
|
||||
# Device Info abrufen
|
||||
device_info = p100.getDeviceInfo()
|
||||
|
||||
if device_info and 'error_code' in device_info:
|
||||
if device_info['error_code'] == 0:
|
||||
device_on = device_info.get('result', {}).get('device_on', False)
|
||||
|
||||
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'}"
|
||||
}
|
||||
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']}"
|
||||
}
|
||||
else:
|
||||
hardware_logger.error(f"❌ Steckdose {ip}: Keine gültige Antwort")
|
||||
return {
|
||||
'success': False,
|
||||
'outlet_on': False,
|
||||
'message': 'Keine gültige Antwort von Steckdose'
|
||||
}
|
||||
|
||||
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)}'
|
||||
}
|
||||
|
||||
# ===== GLOBALE INSTANZ =====
|
||||
|
||||
|
Reference in New Issue
Block a user