diff --git a/html/assets/js/selftest.js b/html/assets/js/selftest.js index fe96879..52b02af 100644 --- a/html/assets/js/selftest.js +++ b/html/assets/js/selftest.js @@ -336,21 +336,27 @@ async function selfTestSequence() { addSelfTestLog(`NPM response: PM1=${npmResult.PM1}, PM2.5=${npmResult.PM25}, PM10=${npmResult.PM10}, status=${npmResult.npm_status_hex}`); // Decode npm_status flags - const status = npmResult.npm_status || 0; - const statusFlags = { - 0x01: "Sleep mode", - 0x02: "Degraded mode", - 0x04: "Not ready", - 0x08: "Heater error", - 0x10: "THP sensor error", - 0x20: "Fan error", - 0x40: "Memory error", - 0x80: "Laser error" - }; - const activeErrors = []; - Object.entries(statusFlags).forEach(([mask, label]) => { - if (status & mask) activeErrors.push(label); - }); + const status = npmResult.npm_status !== undefined ? npmResult.npm_status : 0; + + if (status === 0xFF) { + // 0xFF = no response = disconnected + updateTestStatus(sensor.id, 'Failed', 'Capteur déconnecté', 'bg-danger'); + testsFailed++; + } else { + const statusFlags = { + 0x01: "Sleep mode", + 0x02: "Degraded mode", + 0x04: "Not ready", + 0x08: "Heater error", + 0x10: "THP sensor error", + 0x20: "Fan error", + 0x40: "Memory error", + 0x80: "Laser error" + }; + const activeErrors = []; + Object.entries(statusFlags).forEach(([mask, label]) => { + if (status & mask) activeErrors.push(label); + }); if (activeErrors.length > 0) { updateTestStatus(sensor.id, 'Warning', `Status ${npmResult.npm_status_hex}: ${activeErrors.join(', ')}`, 'bg-warning'); @@ -362,6 +368,7 @@ async function selfTestSequence() { updateTestStatus(sensor.id, 'Warning', 'Incomplete data received', 'bg-warning'); testsFailed++; } + } // end else (not 0xFF) } else if (sensor.type === 'BME280') { // BME280 sensor test diff --git a/html/sensors.html b/html/sensors.html index 1d0367f..b45044f 100755 --- a/html/sensors.html +++ b/html/sensors.html @@ -155,36 +155,51 @@ // NPM status decoded if (response.npm_status !== undefined) { const status = response.npm_status; - const statusText = status === 0 ? "OK" : response.npm_status_hex; - const statusColor = status === 0 ? "green" : "orange"; - $("#data-table-body_" + port).append(` -