Replace individual Envea sensor cards with single debug card
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 <pre> 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 <noreply@anthropic.com>
This commit is contained in:
@@ -569,6 +569,12 @@ if ($type == "envea") {
|
|||||||
echo $output;
|
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") {
|
if ($type == "noise") {
|
||||||
$command = '/var/www/nebuleair_pro_4g/sound_meter/sound_meter';
|
$command = '/var/www/nebuleair_pro_4g/sound_meter/sound_meter';
|
||||||
$output = shell_exec($command);
|
$output = shell_exec($command);
|
||||||
|
|||||||
@@ -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 = `<pre style="background-color: #f5f5f5; padding: 10px; border-radius: 5px; max-height: 500px; overflow-y: auto; font-size: 12px;">${response}</pre>`;
|
||||||
|
},
|
||||||
|
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 = `
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
❌ Error: unable to get debug data from sensors.<br>
|
||||||
|
<small>${status}: ${error}</small>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getNoise_values(){
|
function getNoise_values(){
|
||||||
console.log("Data from I2C Noise Sensor:");
|
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
|
//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) {
|
if (config.envea) {
|
||||||
console.log("Need to display ENVEA sondes");
|
console.log("Need to display ENVEA sondes");
|
||||||
//getting config_scripts table
|
//getting config_scripts table
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'launcher.php?type=get_envea_sondes_table_sqlite',
|
url: 'launcher.php?type=get_envea_sondes_table_sqlite',
|
||||||
dataType:'json',
|
dataType:'json',
|
||||||
//dataType: 'json', // Specify that you expect a JSON response
|
method: 'GET',
|
||||||
method: 'GET', // Use GET or POST depending on your needs
|
|
||||||
success: function(sondes) {
|
success: function(sondes) {
|
||||||
console.log("Getting SQLite envea sondes table:");
|
console.log("Getting SQLite envea sondes table:");
|
||||||
console.log(sondes);
|
console.log(sondes);
|
||||||
const ENVEA_sensors = sondes.filter(sonde => sonde.connected); // Filter only connected sondes
|
const ENVEA_sensors = sondes.filter(sonde => sonde.connected); // Filter only connected sondes
|
||||||
|
|
||||||
ENVEA_sensors.forEach((sensor, index) => {
|
// Only create the card if there are connected sensors
|
||||||
const port = sensor.port; // Port from the sensor object
|
if (ENVEA_sensors.length > 0) {
|
||||||
const name = sensor.name; // Port from the sensor object
|
// Create a single debug card for all Envea sensors
|
||||||
const coefficient = sensor.coefficient;
|
|
||||||
const cardHTML = `
|
const cardHTML = `
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Port UART ${port.replace('ttyAMA', '')}
|
<strong>Sondes Envea (Debug)</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Sonde Envea ${name}</h5>
|
<h5 class="card-title" data-i18n="sensors.envea.title">Sonde Envea</h5>
|
||||||
<p class="card-text" data-i18n="sensors.envea.description">Capteur gas.</p>
|
<p class="card-text" data-i18n="sensors.envea.description">Capteur gaz.</p>
|
||||||
<button class="btn btn-primary" onclick="getENVEA_values('${port}','${name}')" data-i18n="common.getData">Get Data</button>
|
<p class="text-muted small">Sondes connectées: ${ENVEA_sensors.map(s => s.name).join(', ')}</p>
|
||||||
<div id="loading_envea${name}" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
|
<button class="btn btn-primary" onclick="getENVEA_debug_values()" data-i18n="common.getData">Get Data</button>
|
||||||
<table class="table table-striped-columns">
|
<div id="loading_envea_debug" class="spinner-border spinner-border-sm" style="display: none;" role="status"></div>
|
||||||
<tbody id="data-table-body_envea${name}"></tbody>
|
<div id="envea-debug-output" class="mt-3"></div>
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
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();
|
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
|
}//end if envea
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user