Browse Source

Ajout conso nette

master
scayac 2 months ago
parent
commit
0a79fa50df
  1. 22
      data/index.html
  2. 8
      platformio.ini
  3. 33
      src/main.cpp

22
data/index.html

@ -174,6 +174,10 @@ @@ -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 @@ @@ -365,10 +369,17 @@
<div class="data-card consumption">
<div class="data-icon"></div>
<div class="data-label">Consommation</div>
<div class="data-label">Consommation ENEDIS</div>
<div class="data-value" id="consumptionValue">--</div>
<div class="data-unit">Watts</div>
</div>
<div class="data-card net-consumption">
<div class="data-icon">🔌</div>
<div class="data-label">Consommation Nette</div>
<div class="data-value" id="netConsumptionValue">--</div>
<div class="data-unit">Watts</div>
</div>
<div class="data-card heater">
<div class="data-icon">🔥</div>
@ -386,6 +397,7 @@ @@ -386,6 +397,7 @@
<div class="data-value" id="temperatureValue">--</div>
<div class="data-unit">°C</div>
</div>
</div>
<h2>🎛 Mode de Fonctionnement <span class="help-icon" onclick="toggleHelp()">?</span></h2>
@ -665,10 +677,14 @@ @@ -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;

8
platformio.ini

@ -30,7 +30,7 @@ build_flags = @@ -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
;upload_protocol = espota
;upload_port = 192.168.0.29
;upload_flags =
; --auth=password

33
src/main.cpp

@ -52,7 +52,8 @@ unsigned long enphaseUpdateInterval = 5; // En secondes @@ -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() { @@ -441,9 +442,13 @@ void fetchEnphaseData() {
float total = doc[0]["cumulative"]["currW"].as<float>();
float net = doc[1]["cumulative"]["currW"].as<float>();
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() { @@ -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() { @@ -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() { @@ -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() { @@ -1132,8 +1132,11 @@ void setup() {
if (doc["solar_production"]) {
solarProduction = doc["solar_production"].as<float>();
}
if (doc["power_consumption"]) {
powerConsumption = doc["power_consumption"].as<float>();
if (doc["power_import"]) {
powerImport = doc["power_import"].as<float>();
}
if (doc["power_net_consumption"]) {
powerNetConsumption = doc["power_net_consumption"].as<float>();
}
JsonDocument responseDoc;

Loading…
Cancel
Save