fixxed status check
This commit is contained in:
@@ -252,6 +252,39 @@ def api_connect():
|
||||
return jsonify({"success": False, "message": f"Verbindungsfehler: {str(e)}"}), 500
|
||||
|
||||
|
||||
@app.route('/api/status', methods=['GET'])
|
||||
def api_status():
|
||||
"""
|
||||
Einfacher Status-Check: Ist ein Hub verbunden?
|
||||
Wird von Frontend periodisch aufgerufen, um Verbindungsverlust zu erkennen.
|
||||
"""
|
||||
global current_device
|
||||
|
||||
if current_device is None:
|
||||
logger.debug("Status-Check: Kein Device aktiv")
|
||||
return jsonify({
|
||||
"connected": False,
|
||||
"message": "Keine aktive Verbindung"
|
||||
}), 200 # 200 OK, damit der Check nicht als Fehler gilt
|
||||
|
||||
try:
|
||||
# Optional: Hier könnte man später einen echten Test-Befehl machen
|
||||
# z. B. current_device.CreateTelegram() oder nur prüfen, ob Instanz lebt
|
||||
logger.debug("Status-Check: Device vorhanden → verbunden")
|
||||
return jsonify({
|
||||
"connected": True,
|
||||
"message": "Verbunden",
|
||||
"hub_id": current_config.get('hub_id') if current_config else None
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.exception("Status-Check-Fehler")
|
||||
return jsonify({
|
||||
"connected": False,
|
||||
"message": f"Verbindungsfehler: {str(e)}"
|
||||
}), 200 # immer 200, damit Frontend entscheidet
|
||||
|
||||
|
||||
@app.route('/api/control', methods=['POST'])
|
||||
def api_control():
|
||||
global current_device
|
||||
|
||||
Reference in New Issue
Block a user