diff --git a/data/index.html b/data/index.html index 29cdfeb..ed04717 100644 --- a/data/index.html +++ b/data/index.html @@ -174,6 +174,10 @@ background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%); color: white; } + .data-card.net-consumption { + background: linear-gradient(135deg, #55efc4 0%, #38ada9 100%); + color: white; + } .data-icon { font-size: 32px; margin-bottom: 5px; @@ -365,10 +369,17 @@
⚡
-
Consommation
+
Consommation ENEDIS
--
Watts
+ +
+
🔌
+
Consommation Nette
+
--
+
Watts
+
đŸ”„
@@ -386,6 +397,7 @@
--
°C
+

đŸŽ›ïž Mode de Fonctionnement ?

@@ -665,10 +677,14 @@ document.getElementById('solarValue').textContent = data.solar_production.toFixed(0); - // Mettre Ă  jour la consommation + // Mettre Ă  jour la consommation importĂ©e document.getElementById('consumptionValue').textContent = - data.power_consumption.toFixed(0); + data.power_import.toFixed(0); + // Mettre Ă  jour la consommation nette + document.getElementById('netConsumptionValue').textContent = + data.power_net_consumption.toFixed(0); + // Mettre Ă  jour la puissance du chauffe-eau document.getElementById('heaterValue').textContent = data.heater_power; diff --git a/platformio.ini b/platformio.ini index 99d8e62..9389c6b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,7 +30,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DBOARD_HAS_PSRAM ; Configuration ArduinoOTA pour firmware et filesystem -; upload_protocol = espota -; upload_port = 192.168.0.29 -; upload_flags = -; --auth=password \ No newline at end of file +;upload_protocol = espota +;upload_port = 192.168.0.29 +;upload_flags = +; --auth=password \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c516a8f..24da5c6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,8 @@ unsigned long enphaseUpdateInterval = 5; // En secondes // DonnĂ©es de mesure en temps rĂ©el float solarProduction = 0.0; // Production solaire en Watts -float powerConsumption = 0.0; // Consommation Ă©lectrique en Watts +float powerImport = 0.0; // Consommation Ă©lectrique inportĂ©e depuis ENEDIS en Watts +float powerNetConsumption = 0.0; // Consommation nette (net) en Watts int heaterPower = 0; // Puissance de chauffe du chauffe-eau en % (0-100) float waterTemperature = 0.0; // TempĂ©rature de l'eau du chauffe-eau en °C // Flag pour l'Ă©tat de la connexion Enphase @@ -441,9 +442,13 @@ void fetchEnphaseData() { float total = doc[0]["cumulative"]["currW"].as(); float net = doc[1]["cumulative"]["currW"].as(); solarProduction = round(total - net); // Production des panneaux arrondie - powerConsumption = round(total); // Consommation totale arrondie - Serial.printf("Enphase - Total: %.1fW, Panneaux: %.1fW, Net: %.1fW\n", - total, solarProduction, net); + if (solarProduction < 0) { + solarProduction = 0; // Éviter les valeurs nĂ©gatives + } + powerImport = round(net); // Consommation totale enedis arrondie + powerNetConsumption = round(total); // Consommation de la maison + Serial.printf("Enphase - Total: %.1fW, Panneaux: %.1fW, Enedis: %.1fW\n", + powerNetConsumption, solarProduction, powerImport); enphaseConnectionError = false; } else { Serial.println("Erreur parsing JSON Enphase"); @@ -500,7 +505,6 @@ void calculateHeaterPower() { } // Calculer l'excĂ©dent solaire et ajuster le pourcentage de chauffe - float solarExcess = 0; int calculatedHeaterPowerJour = 0; int calculatedHeaterPowerSoleil = 0; int calculatedHeaterPower = heaterPower; @@ -577,19 +581,14 @@ void calculateHeaterPower() { } if (modeSOLEIL) { - - //Calculer l'excĂ©dent solaire - solarExcess = solarProduction - powerConsumption; // Mode SOLEIL: ajuster selon l'excĂ©dent solaire - if (solarExcess > 0) { + if (powerImport <= 0) { // Convertir l'excĂ©dent solaire en pourcentage (max = puissance max du chauffe-eau) - calculatedHeaterPowerSoleil = (int)((solarExcess * 100) / heaterMaxPower); + calculatedHeaterPowerSoleil = (int)(((abs(powerImport)) * 100) / heaterMaxPower); if (calculatedHeaterPowerSoleil > 100) calculatedHeaterPowerSoleil = 100; - // Serial.printf("[SOLEIL] ExcĂ©dent: %.1fW, Chauffe: %d%%\n", solarExcess, calculatedHeaterPowerSoleil); } else { calculatedHeaterPowerSoleil = 0; - // Serial.printf("[SOLEIL] Pas d'excĂ©dent solaire (%.1fW), chauffe-eau dĂ©sactivĂ©\n", solarExcess); } } // Prendre le maximum entre les deux modes @@ -1091,7 +1090,8 @@ void setup() { JsonDocument doc; doc["solar_production"] = solarProduction; - doc["power_consumption"] = powerConsumption; + doc["power_import"] = powerImport; + doc["power_net_consumption"] = powerNetConsumption; doc["heater_power"] = heaterPower; doc["water_temperature"] = waterTemperature; doc["sunrise_time"] = sunriseTime; @@ -1132,8 +1132,11 @@ void setup() { if (doc["solar_production"]) { solarProduction = doc["solar_production"].as(); } - if (doc["power_consumption"]) { - powerConsumption = doc["power_consumption"].as(); + if (doc["power_import"]) { + powerImport = doc["power_import"].as(); + } + if (doc["power_net_consumption"]) { + powerNetConsumption = doc["power_net_consumption"].as(); } JsonDocument responseDoc;