|
|
|
|
@ -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; |
|
|
|
|
|