j ai un fait html pour tester
voici le résultat
![[Image: Screenshot-20250622-234629-Code-Editor.jpg]](https://i.ibb.co/FLK9wjmV/Screenshot-20250622-234629-Code-Editor.jpg)
chez moi le shelly met a jour la puissance en moins d une seconde
Code :
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Test total_power Shelly</title>
<style>
body { font-family: sans-serif; }
table { border-collapse: collapse; width: 100%; margin-top: 1em; }
th, td { border: 1px solid #ccc; padding: 0.5em; text-align: left; }
th { background: #eee; }
</style>
</head>
<body>
<h1>Test de total_power (Shelly 3EM)</h1>
<button onclick="testerShelly()">Démarrer le test</button>
<table id="resultats">
<thead>
<tr>
<th>#</th>
<th>total_power (W)</th>
<th>Temps écoulé (ms)</th>
<th>Statut</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
async function testerShelly() {
const url = "http://192.168.1.27/status";
const tbody = document.querySelector("#resultats tbody");
tbody.innerHTML = ""; // Réinitialise le tableau
const debutTest = performance.now();
for (let i = 1; i <= 10; i++) {
let totalPower = "?";
let temps = (performance.now() - debutTest).toFixed(2);
let statut = "OK";
try {
const response = await fetch(url, { method: 'GET' });
if (!response.ok) {
statut = `HTTP ${response.status}`;
} else {
const donnees = await response.json();
totalPower = donnees?.total_power ?? "inconnu";
}
} catch (err) {
statut = "Erreur réseau";
}
temps = (performance.now() - debutTest).toFixed(2);
// Ajoute une ligne au tableau
const ligne = document.createElement("tr");
ligne.innerHTML = `
<td>${i}</td>
<td>${totalPower}</td>
<td>${temps}</td>
<td>${statut}</td>
`;
tbody.appendChild(ligne);
await new Promise(resolve => setTimeout(resolve, 200));
}
}
</script>
</body>
</html>
voici le résultat
![[Image: Screenshot-20250622-234629-Code-Editor.jpg]](https://i.ibb.co/FLK9wjmV/Screenshot-20250622-234629-Code-Editor.jpg)
chez moi le shelly met a jour la puissance en moins d une seconde