updated app.js

This commit is contained in:
2026-02-12 21:25:43 +01:00
parent 7adda970fb
commit 60eec88332
2 changed files with 39 additions and 26 deletions
+16 -11
View File
@@ -254,37 +254,42 @@ def api_connect():
@app.route('/api/status', methods=['GET'])
def api_status():
global current_device, current_module, current_hub # ← Global am Anfang!
global current_device, current_module, current_hub
if current_device is None:
logger.debug("Status-Check: Kein Device aktiv")
return jsonify({
"connected": False,
"message": "Keine aktive Verbindung"
}), 200
return jsonify({"connected": False, "message": "Keine aktive Verbindung"}), 200
try:
# Echter Mini-Test: Setze Kanal 0 (A) auf 0.0
# Harter Test: Setze Kanal 0 (A) kurz auf 0.1 und sofort zurück auf 0.0
# Das ist fast unsichtbar (nur ein minimaler Impuls), aber zwingt den Hub zu reagieren
current_device.SetChannel(0, 0.1)
current_device.SetChannel(0, 0.0)
logger.debug("Status-Check: SetChannel(0, 0.0) erfolgreich → Hub antwortet")
logger.debug("Status-Check: Harter Test (SetChannel 0.1 → 0.0) erfolgreich → Hub lebt")
return jsonify({
"connected": True,
"message": "Verbunden"
})
except Exception as e:
logger.warning(f"Status-Check: SetChannel-Test fehlgeschlagen → Hub wahrscheinlich weg: {e}")
# Verbindung sauber beenden
logger.warning(f"Status-Check: Harter Test fehlgeschlagen → Hub wahrscheinlich weg: {str(e)}")
# Sauber aufräumen
try:
current_device.Disconnect()
except:
pass
current_device = None
current_module = None
current_hub = None
return jsonify({"connected": False, "message": f"Hub reagiert nicht: {str(e)}"}), 200
return jsonify({
"connected": False,
"message": f"Hub reagiert nicht mehr: {str(e)}"
}), 200
@app.route('/api/control', methods=['POST'])