v1.12.3: defaut CO2 = sentinelle ISO_17 seule (retrait bit 7)
Decision avec le dev serveur Miotiq: l'absence/defaut du capteur CO2 est signalee uniquement par ISO_17=0xFFFF (sentinelle, source de verite). Le bit 7 error_flags ajoute en v1.12.2 est retire (ambigu WIND/CO2 selon device_type). - SARA_send_data_v2.py: suppression ERR_CO2 + s88_disconnected + |= ERR_CO2 - la logique sentinelle (set_co2 seulement si s88_status==0) reste inchangee - error_flags.md: bit 7 = WIND_ERROR, note que le CO2 passe par la sentinelle On garde v1.12.1 (s88_status + ecriture systematique) qui garantit la sentinelle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -160,10 +160,6 @@ ERR_ENVEA = 0x10
|
||||
ERR_NOISE = 0x20
|
||||
ERR_MPPT = 0x40
|
||||
ERR_WIND = 0x80
|
||||
# Bit 7 is dual-purpose per product (server decodes by device_type):
|
||||
# NebuleAir -> WIND_ERROR, ModuleAir / CO2-equipped units -> CO2_ERROR.
|
||||
# On these CO2 boxes the server reads bit 7 as CO2_ERROR (confirmed).
|
||||
ERR_CO2 = 0x80
|
||||
|
||||
# database connection
|
||||
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
|
||||
@@ -1091,9 +1087,10 @@ try:
|
||||
# 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.
|
||||
# Absence is signalled two ways: the 0xFFFF sentinel in the CO2 field, and
|
||||
# the CO2_ERROR bit (0x80) in error_flags (byte 66) — see build below.
|
||||
s88_disconnected = False
|
||||
# Absence/fault is signalled solely by the 0xFFFF sentinel in the CO2 field
|
||||
# (ISO_17, source of truth per the Miotiq spec): only transmit when the LAST
|
||||
# reading is valid (s88_status == 0). No error_flags bit — bit 7 is ambiguous
|
||||
# (WIND on NebuleAir / CO2 on ModuleAir), the sentinel is unambiguous.
|
||||
if s88_sensor:
|
||||
print("➡️Getting S88 CO2 value")
|
||||
cursor.execute("SELECT * FROM data_S88 ORDER BY rowid DESC LIMIT 1")
|
||||
@@ -1105,11 +1102,9 @@ try:
|
||||
print(f"CO2 (S88): {co2_ppm} ppm")
|
||||
payload.set_co2(co2_ppm)
|
||||
else:
|
||||
s88_disconnected = True
|
||||
print(f"S88 last reading invalid (s88_status=0x{s88_status_value:02X}) -> CO2 marked absent (0xFFFF), set CO2_ERROR")
|
||||
print(f"S88 last reading invalid (s88_status=0x{s88_status_value:02X}) -> CO2 marked absent (0xFFFF)")
|
||||
else:
|
||||
s88_disconnected = True
|
||||
print("No S88 data available in the database. -> set CO2_ERROR")
|
||||
print("No S88 data available in the database. -> CO2 marked absent (0xFFFF)")
|
||||
|
||||
#print("Verify SARA connection (AT)")
|
||||
|
||||
@@ -1243,8 +1238,6 @@ try:
|
||||
error_flags |= ERR_NPM
|
||||
if noise_disconnected:
|
||||
error_flags |= ERR_NOISE
|
||||
if s88_disconnected:
|
||||
error_flags |= ERR_CO2 # bit 7, read as CO2_ERROR by the server on these units
|
||||
payload.set_error_flags(error_flags)
|
||||
|
||||
# ---- Firmware version (bytes 69-71) ----
|
||||
|
||||
Reference in New Issue
Block a user