From 4e5e1a8144d3e7083ec42308bf3742c20a0e4947 Mon Sep 17 00:00:00 2001 From: PaulVua Date: Mon, 1 Jun 2026 17:03:07 +0200 Subject: [PATCH] v1.9.18: fix OTA - create_db.py manquant dans update scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les MAJ OTA ne lancent pas create_db.py, donc toute nouvelle table ajoutée par une release (ex: data_S88) reste inexistante en base. Les timers tournent, le script s'exécute, mais l'INSERT échoue silencieusement avec 'no such table' — capturé par le try/except, exit 0, systemd voit success. Symptôme observé sur les capteurs avec S88 activé: 'Get Data' marche (live read), mais 'Mesures CO2 (Senseair S88)' montre 'Aucune donnée disponible dans cette table'. Fix: create_db.py est appelé en step 2 juste avant set_config.py dans les deux scripts d'update (git pull et upload fichier). Idempotent (CREATE IF NOT EXISTS + ALTER ADD COLUMN in try/except). Self-bootstrap: après cette OTA, tous les capteurs auront toutes les tables, y compris celles introduites dans des releases passées. Co-Authored-By: Claude Opus 4.7 (1M context) --- VERSION | 2 +- changelog.json | 13 +++++++++++++ update_firmware.sh | 11 +++++++++-- update_firmware_from_file.sh | 9 +++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index eea55cf..f60acf7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.17 +1.9.18 diff --git a/changelog.json b/changelog.json index 3861db5..3378e16 100644 --- a/changelog.json +++ b/changelog.json @@ -1,5 +1,18 @@ { "versions": [ + { + "version": "1.9.18", + "date": "2026-06-01", + "changes": { + "features": [], + "improvements": [], + "fixes": [ + "OTA update: appel manquant à sqlite/create_db.py dans update_firmware.sh et update_firmware_from_file.sh. Conséquence: les MAJ qui ajoutaient une nouvelle table (data_S88, data_NOISE.noise_status, etc.) laissaient les timers tourner mais chaque écriture échouait silencieusement avec 'no such table'. Désormais create_db.py est appelé en step 2 juste avant set_config.py — idempotent (CREATE IF NOT EXISTS + ALTER ADD COLUMN in try/except), safe à chaque OTA." + ], + "compatibility": [] + }, + "notes": "Fix self-bootstrap: dès qu'un capteur fait une OTA après cette version, create_db.py s'exécute et crée toutes les tables manquantes. Pour les capteurs déjà sur v1.9.13–v1.9.17 qui ont activé S88 sans table data_S88, la prochaine OTA résoudra automatiquement." + }, { "version": "1.9.17", "date": "2026-06-01", diff --git a/update_firmware.sh b/update_firmware.sh index dd8f127..12d083f 100755 --- a/update_firmware.sh +++ b/update_firmware.sh @@ -62,9 +62,16 @@ if [ -f "/var/www/nebuleair_pro_4g/VERSION" ]; then print_status "Firmware version: $(cat /var/www/nebuleair_pro_4g/VERSION)" fi -# Step 2: Update database configuration +# Step 2: Update database (schema migration + config keys) +# create_db.py is idempotent (CREATE TABLE IF NOT EXISTS + ALTER TABLE ADD COLUMN +# wrapped in try/except). Required to add tables introduced after the sensor was +# initially provisioned (e.g. data_S88, data_NOISE.noise_status, ...). +# Without this step, OTA updates that add a new sensor table leave the timer running +# but every write fails with "no such table". print_status "" -print_status "Step 2: Updating database configuration..." +print_status "Step 2: Updating database (schema migration + config keys)..." +/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py +check_status "Database schema migration" /usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/set_config.py check_status "Database configuration update" diff --git a/update_firmware_from_file.sh b/update_firmware_from_file.sh index 32bd08e..8f6d030 100644 --- a/update_firmware_from_file.sh +++ b/update_firmware_from_file.sh @@ -98,9 +98,14 @@ print_status "Fixing ownership..." chown -R www-data:www-data "$TARGET_DIR/" check_status "Ownership fix (chown)" -# Step 3: Update database configuration +# Step 3: Update database (schema migration + config keys) +# create_db.py is idempotent; required to add tables introduced after the sensor +# was provisioned. Without it, OTA leaves new-sensor timers running but every +# write fails with "no such table". print_status "" -print_status "Step 3: Updating database configuration..." +print_status "Step 3: Updating database (schema migration + config keys)..." +/usr/bin/python3 "$TARGET_DIR/sqlite/create_db.py" +check_status "Database schema migration" /usr/bin/python3 "$TARGET_DIR/sqlite/set_config.py" check_status "Database configuration update"