v1.12.1: S88 ecrit toujours + code d'etat, plus de CO2 perime transmis

Probleme vu sur pro100: sonde S88 muette (panne cablage) mais write_data.py
n'ecrivait rien -> la base gardait la derniere valeur (487 ppm d'hier) et la
loop d'envoi la transmettait en boucle.

- data_S88: nouvelle colonne s88_status (0=OK, 0xFF=sonde muette), comme
  npm_status/noise_status. Migration via create_db.py + set_config.py + self-heal.
- S88/write_data.py: ecrit DESORMAIS une ligne a chaque cycle (CO2=0 + 0xFF si
  pas de reponse). Connexion SQLite timeout=10 (anti database-is-locked).
- SARA_send_data_v2.py: lit s88_status; si 0xFF -> bytes 81-82 restent 0xFFFF
  (CO2 absent) au lieu d'envoyer une valeur perimee. Compatible bases non migrees.
- database.html + launcher.php: badge statut + colonne dans les exports CSV.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-06-02 17:10:32 +02:00
parent dad953acdc
commit d554f03195
8 changed files with 101 additions and 34 deletions

View File

@@ -1084,14 +1084,23 @@ try:
)
# S88 CO2 sensor (Senseair S88, NDIR) -> byte 81-82 (ISO_17, uint16 ppm)
# Only transmit when the LAST reading is valid (s88_status == 0). If the
# sensor is down (s88_status == 0xFF), leave bytes 81-82 at 0xFFFF (= "CO2
# sensor absent" in the Miotiq spec) instead of sending a stale value.
# NB: byte 66 (error_flags) is already full, so absence is signalled solely
# by the 0xFFFF sentinel in the CO2 field.
if s88_sensor:
print("Getting S88 CO2 value")
cursor.execute("SELECT * FROM data_S88 ORDER BY rowid DESC LIMIT 1")
last_row = cursor.fetchone()
if last_row and last_row[1] is not None:
if last_row:
co2_ppm = last_row[1]
print(f"CO2 (S88): {co2_ppm} ppm")
payload.set_co2(co2_ppm)
s88_status_value = last_row[2] if len(last_row) > 2 and last_row[2] is not None else 0x00
if s88_status_value == 0x00 and co2_ppm is not None:
print(f"CO2 (S88): {co2_ppm} ppm")
payload.set_co2(co2_ppm)
else:
print(f"S88 last reading invalid (s88_status=0x{s88_status_value:02X}) -> CO2 marked absent (0xFFFF)")
else:
print("No S88 data available in the database.")