v1.12.2: flag CO2_ERROR (bit 7) quand la sonde S88 est deconnectee
A la demande: en plus du sentinel 0xFFFF dans le champ CO2, on remonte le defaut via error_flags byte 66 bit 7. - ERR_CO2 = 0x80 (bit 7, double sens vent/CO2 selon device_type cote serveur) - s88_disconnected -> error_flags |= ERR_CO2 dans SARA_send_data_v2.py - error_flags.md: bit 7 documente comme WIND_ERROR / CO2_ERROR Confirme par le user: le serveur lit le bit 7 comme CO2_ERROR sur ces unites. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,10 @@ 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")
|
||||
@@ -1087,8 +1091,9 @@ 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.
|
||||
# NB: byte 66 (error_flags) is already full, so absence is signalled solely
|
||||
# by the 0xFFFF sentinel in the CO2 field.
|
||||
# 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
|
||||
if s88_sensor:
|
||||
print("➡️Getting S88 CO2 value")
|
||||
cursor.execute("SELECT * FROM data_S88 ORDER BY rowid DESC LIMIT 1")
|
||||
@@ -1100,9 +1105,11 @@ try:
|
||||
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)")
|
||||
s88_disconnected = True
|
||||
print(f"S88 last reading invalid (s88_status=0x{s88_status_value:02X}) -> CO2 marked absent (0xFFFF), set CO2_ERROR")
|
||||
else:
|
||||
print("No S88 data available in the database.")
|
||||
s88_disconnected = True
|
||||
print("No S88 data available in the database. -> set CO2_ERROR")
|
||||
|
||||
#print("Verify SARA connection (AT)")
|
||||
|
||||
@@ -1236,6 +1243,8 @@ 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