v1.9.10: Self Test - check sous-tension (vcgencmd get_throttled)
Ajoute un test 'Power Supply' au Self Test pour détecter une sous-tension du Pi (cause fréquente de capteurs USB instables, corruptions SD, reboots). Endpoint launcher.php?type=throttled + script power/get_throttled.py (lancé via sudo python3, déjà whitelisté — pas de modif sudoers). Affiché en tête des résultats et dans le rapport copiable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,10 @@ function resetSelfTestUI() {
|
||||
</div>`;
|
||||
|
||||
// Reset test items
|
||||
document.getElementById('test_power_status').className = 'badge bg-secondary';
|
||||
document.getElementById('test_power_status').textContent = 'Pending';
|
||||
document.getElementById('test_power_detail').textContent = 'Waiting...';
|
||||
|
||||
document.getElementById('test_wifi_status').className = 'badge bg-secondary';
|
||||
document.getElementById('test_wifi_status').textContent = 'Pending';
|
||||
document.getElementById('test_wifi_detail').textContent = 'Waiting...';
|
||||
@@ -260,6 +264,59 @@ async function selfTestSequence() {
|
||||
|
||||
await delaySelfTest(300);
|
||||
|
||||
// ═══════════════════════════════════════════════════════
|
||||
// SYSTEM TEST - Power supply (under-voltage detection)
|
||||
// ═══════════════════════════════════════════════════════
|
||||
addSelfTestLog('');
|
||||
addSelfTestLog('────────────────────────────────────────────────────────');
|
||||
addSelfTestLog('SYSTEM TEST');
|
||||
addSelfTestLog('────────────────────────────────────────────────────────');
|
||||
|
||||
document.getElementById('selftest_status').innerHTML = `
|
||||
<div class="d-flex align-items-center text-primary">
|
||||
<div class="spinner-border spinner-border-sm me-2" role="status"></div>
|
||||
<span>Checking power supply...</span>
|
||||
</div>`;
|
||||
|
||||
updateTestStatus('power', 'Testing...', 'Reading vcgencmd get_throttled...', 'bg-info');
|
||||
addSelfTestLog('Checking power supply (under-voltage)...');
|
||||
|
||||
try {
|
||||
const powerResult = await new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=throttled',
|
||||
dataType: 'json',
|
||||
method: 'GET',
|
||||
cache: false,
|
||||
timeout: 10000,
|
||||
success: function(data) { resolve(data); },
|
||||
error: function(xhr, status, error) { reject(new Error(error || status)); }
|
||||
});
|
||||
});
|
||||
|
||||
selfTestReport.rawResponses['Power Supply'] = JSON.stringify(powerResult, null, 2);
|
||||
addSelfTestLog(`Power response: ${JSON.stringify(powerResult)}`);
|
||||
|
||||
if (!powerResult.available) {
|
||||
updateTestStatus('power', 'Warning', powerResult.error || 'vcgencmd indisponible', 'bg-warning');
|
||||
testsFailed++;
|
||||
} else if (powerResult.status === 'critical') {
|
||||
updateTestStatus('power', 'Failed', powerResult.message, 'bg-danger');
|
||||
testsFailed++;
|
||||
} else if (powerResult.status === 'warning') {
|
||||
updateTestStatus('power', 'Warning', powerResult.message, 'bg-warning');
|
||||
testsFailed++;
|
||||
} else {
|
||||
updateTestStatus('power', 'Passed', powerResult.message || 'Alimentation OK', 'bg-success');
|
||||
testsPassed++;
|
||||
}
|
||||
} catch (error) {
|
||||
addSelfTestLog(`Power supply test error: ${error.message}`);
|
||||
updateTestStatus('power', 'Failed', error.message, 'bg-danger');
|
||||
selfTestReport.rawResponses['Power Supply'] = `ERROR: ${error.message}`;
|
||||
testsFailed++;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════
|
||||
// SENSOR TESTS - Test enabled sensors based on config
|
||||
// ═══════════════════════════════════════════════════════
|
||||
@@ -856,6 +913,7 @@ GPS Location: ${selfTestReport.latitude || 'N/A'}, ${selfTestReport.longitud
|
||||
|
||||
// Add test results (sensors first, then communication)
|
||||
const testNames = {
|
||||
power: 'Power Supply',
|
||||
npm: 'NextPM (Particles)',
|
||||
bme280: 'BME280 (Temp/Hum)',
|
||||
noise: 'Noise Sensor',
|
||||
|
||||
Reference in New Issue
Block a user