From 4f1b140a750b9bcae65ba709280c7f57fee40253 Mon Sep 17 00:00:00 2001 From: PaulVua Date: Wed, 7 Jan 2026 14:56:08 +0100 Subject: [PATCH] Replace individual Envea sensor cards with single debug card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified the sensors page to display a unified debug view for all Envea gas sensors: Backend changes: - Added new 'envea_debug' endpoint in launcher.php - Calls: /usr/bin/python3 /var/www/nebuleair_pro_4g/envea/read_value_v2.py -d - Returns raw debug output without parsing Frontend changes: - Replaced individual sensor cards with single combined card - Card displays if any gas sensor is connected - Shows list of connected sensors (NO2, H2S, NH3, etc.) - New getENVEA_debug_values() function fetches debug data - Raw output displayed in scrollable
 block
- No JSON parsing, no table formatting - just raw debug text
- Card width set to col-sm-6 for better visibility

This makes it easier to check if all sensors are working correctly by viewing the raw output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 
---
 html/launcher.php |  6 ++++
 html/sensors.html | 79 +++++++++++++++++++++++++++++++----------------
 2 files changed, 58 insertions(+), 27 deletions(-)

diff --git a/html/launcher.php b/html/launcher.php
index 2a67916..52c603d 100755
--- a/html/launcher.php
+++ b/html/launcher.php
@@ -569,6 +569,12 @@ if ($type == "envea") {
     echo $output;
 }
 
+if ($type == "envea_debug") {
+    $command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/envea/read_value_v2.py -d 2>&1';
+    $output = shell_exec($command);
+    echo $output;
+}
+
 if ($type == "noise") {
     $command = '/var/www/nebuleair_pro_4g/sound_meter/sound_meter';
     $output = shell_exec($command);
diff --git a/html/sensors.html b/html/sensors.html
index 3a6b716..241a013 100755
--- a/html/sensors.html
+++ b/html/sensors.html
@@ -190,6 +190,37 @@ function getENVEA_values(port, name){
     });
 }
 
+function getENVEA_debug_values(){
+    console.log("Getting debug data from all Envea sensors");
+    $("#loading_envea_debug").show();
+
+    $.ajax({
+        url: 'launcher.php?type=envea_debug',
+        dataType: 'text',
+        method: 'GET',
+        success: function(response) {
+            console.log("Envea debug output:", response);
+            const outputDiv = document.getElementById("envea-debug-output");
+            $("#loading_envea_debug").hide();
+
+            // Display raw output in a pre block
+            outputDiv.innerHTML = `
${response}
`; + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + const outputDiv = document.getElementById("envea-debug-output"); + $("#loading_envea_debug").hide(); + + outputDiv.innerHTML = ` +
+ ❌ Error: unable to get debug data from sensors.
+ ${status}: ${error} +
+ `; + } + }); +} + function getNoise_values(){ console.log("Data from I2C Noise Sensor:"); @@ -385,55 +416,49 @@ error: function(xhr, status, error) { } //Si on a des SONDES ENVEA connectée il faut faire un deuxième call dans la table envea_sondes_table - //creates ENVEA cards + //creates ENVEA debug card if (config.envea) { console.log("Need to display ENVEA sondes"); //getting config_scripts table $.ajax({ url: 'launcher.php?type=get_envea_sondes_table_sqlite', dataType:'json', - //dataType: 'json', // Specify that you expect a JSON response - method: 'GET', // Use GET or POST depending on your needs + method: 'GET', success: function(sondes) { console.log("Getting SQLite envea sondes table:"); console.log(sondes); const ENVEA_sensors = sondes.filter(sonde => sonde.connected); // Filter only connected sondes - ENVEA_sensors.forEach((sensor, index) => { - const port = sensor.port; // Port from the sensor object - const name = sensor.name; // Port from the sensor object - const coefficient = sensor.coefficient; + // Only create the card if there are connected sensors + if (ENVEA_sensors.length > 0) { + // Create a single debug card for all Envea sensors const cardHTML = ` -
+
- Port UART ${port.replace('ttyAMA', '')} + Sondes Envea (Debug)
-
Sonde Envea ${name}
-

Capteur gas.

- - - - -
+
Sonde Envea
+

Capteur gaz.

+

Sondes connectées: ${ENVEA_sensors.map(s => s.name).join(', ')}

+ + +
`; - container.innerHTML += cardHTML; // Ajouter la carte au conteneur - }); + container.innerHTML += cardHTML; + } - // Apply translations to dynamically created Envea cards + // Apply translations to dynamically created Envea card i18n.applyTranslations(); - - - - }, - error: function(xhr, status, error) { - console.error('AJAX request failed:', status, error); - } - });//end AJAX envea Sondes + }, + error: function(xhr, status, error) { + console.error('AJAX request failed:', status, error); + } + });//end AJAX envea Sondes }//end if envea