update for app.js

This commit is contained in:
2026-02-16 11:24:23 +01:00
parent b8b2aec67d
commit d081477d63
11 changed files with 432 additions and 449 deletions
+13 -8
View File
@@ -42,16 +42,20 @@ def cleanup_old_log_dirs(max_age_days=90):
logger.error(f"Fehler beim Löschen von {subdir_path}: {e}")
# ── Hilfsfunktion - globale Sounds laden ────────────────────────────────────────────────────────────────
def load_global_sounds():
global_sounds_path = os.path.join(app.root_path, 'sounds.json') # oder configs/sounds.json
if os.path.exists(global_sounds_path):
def load_default_sounds():
path = os.path.join(app.config['CONFIG_DIR'], 'default_sounds.json')
if os.path.exists(path):
try:
with open(global_sounds_path, 'r', encoding='utf-8') as f:
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
return data.get('global_sounds', [])
# sounds = data.get('global_sounds', data.get('sounds', [])) # flexibel
sounds = data.get('global_sounds', [])
logger.info(f"Globale Default-Sounds geladen: {len(sounds)} Einträge")
return sounds
except Exception as e:
logger.error(f"Fehler beim Laden globaler Sounds: {e}")
logger.error(f"Fehler beim Laden default_sounds.json: {e}")
return []
logger.info("Keine default_sounds.json gefunden")
return []
# ── Bluetooth ────────────────────────────────────────────────────────────────
@@ -164,7 +168,7 @@ logger.info("Background-Monitor für Hub-Verbindung gestartet")
def load_configs():
configs = []
for filename in os.listdir(app.config['CONFIG_DIR']):
if filename.lower().endswith('.json'):
if filename.lower().endswith('.json') and filename != 'default_sounds.json':
path = os.path.join(app.config['CONFIG_DIR'], filename)
try:
with open(path, 'r', encoding='utf-8') as f:
@@ -234,7 +238,8 @@ def control_page():
if current_config is None:
logger.warning("current_config ist None → Redirect zu index")
return redirect(url_for('index'))
# Globale Sounds immer laden
global_sounds = load_global_sounds()
logger.info(f"Übergebe config an Template: {current_config}")