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;