52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!/usr/bin/env python3.11
|
|
"""
|
|
Direkter Test der Tapo-Steckdosen-Funktionalität
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Pfad zum Backend hinzufügen
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from utils.tapo_controller import tapo_controller
|
|
from models import get_db_session, Printer
|
|
|
|
def test_tapo_functionality():
|
|
"""Testet die Tapo-Funktionalität direkt"""
|
|
|
|
print('🔧 Teste Tapo-Controller...')
|
|
|
|
db_session = get_db_session()
|
|
|
|
try:
|
|
printers = db_session.query(Printer).filter(
|
|
Printer.plug_ip.isnot(None)
|
|
).order_by(Printer.plug_ip).all()
|
|
|
|
print(f"📊 Gefunden: {len(printers)} Tapo-Steckdosen")
|
|
|
|
for printer in printers:
|
|
print(f'\n📍 Teste {printer.plug_ip} ({printer.name})...')
|
|
|
|
try:
|
|
reachable, status = tapo_controller.check_outlet_status(
|
|
printer.plug_ip,
|
|
printer_id=printer.id
|
|
)
|
|
|
|
if reachable:
|
|
print(f' ✅ Erreichbar - Status: {status}')
|
|
else:
|
|
print(f' ⚠️ Nicht erreichbar - Status: {status}')
|
|
|
|
except Exception as e:
|
|
print(f' ❌ Fehler: {e}')
|
|
|
|
finally:
|
|
db_session.close()
|
|
|
|
print('\n✅ Test abgeschlossen.')
|
|
|
|
if __name__ == "__main__":
|
|
test_tapo_functionality() |