diff --git a/include/Configuration.h b/include/Configuration.h index cda482652..92b3bff69 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -253,6 +253,7 @@ struct CONFIG_T { float Auto_Power_Lower_Power_Limit; float Auto_Power_Upper_Power_Limit; uint8_t Auto_Power_Stop_BatterySoC_Threshold; + float Auto_Power_Target_Power_Consumption; } Huawei; diff --git a/include/defaults.h b/include/defaults.h index 487c3df61..237a94b06 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -157,5 +157,6 @@ #define HUAWEI_AUTO_POWER_LOWER_POWER_LIMIT 150 #define HUAWEI_AUTO_POWER_UPPER_POWER_LIMIT 2000 #define HUAWEI_AUTO_POWER_STOP_BATTERYSOC_THRESHOLD 95 +#define HUAWEI_AUTO_POWER_TARGET_POWER_CONSUMPTION 0 #define VERBOSE_LOGGING true diff --git a/src/Configuration.cpp b/src/Configuration.cpp index b6565715e..d79953787 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -227,6 +227,7 @@ bool ConfigurationClass::write() huawei["lower_power_limit"] = config.Huawei.Auto_Power_Lower_Power_Limit; huawei["upper_power_limit"] = config.Huawei.Auto_Power_Upper_Power_Limit; huawei["stop_batterysoc_threshold"] = config.Huawei.Auto_Power_Stop_BatterySoC_Threshold; + huawei["target_power_consumption"] = config.Huawei.Auto_Power_Target_Power_Consumption; // Serialize JSON to file if (serializeJson(doc, f) == 0) { @@ -482,6 +483,7 @@ bool ConfigurationClass::read() config.Huawei.Auto_Power_Lower_Power_Limit = huawei["lower_power_limit"] | HUAWEI_AUTO_POWER_LOWER_POWER_LIMIT; config.Huawei.Auto_Power_Upper_Power_Limit = huawei["upper_power_limit"] | HUAWEI_AUTO_POWER_UPPER_POWER_LIMIT; config.Huawei.Auto_Power_Stop_BatterySoC_Threshold = huawei["stop_batterysoc_threshold"] | HUAWEI_AUTO_POWER_STOP_BATTERYSOC_THRESHOLD; + config.Huawei.Auto_Power_Target_Power_Consumption = huawei["target_power_consumption"] | HUAWEI_AUTO_POWER_TARGET_POWER_CONSUMPTION; f.close(); return true; diff --git a/src/Huawei_can.cpp b/src/Huawei_can.cpp index 4c5e42d39..6cd41b4fa 100644 --- a/src/Huawei_can.cpp +++ b/src/Huawei_can.cpp @@ -384,7 +384,11 @@ void HuaweiCanClass::loop() // Calculate new power limit float newPowerLimit = -1 * round(PowerMeter.getPowerTotal()); - newPowerLimit += _rp.output_power; + float efficiency = (_rp.efficiency > 0.5 ? _rp.efficiency : 1.0); + + // Powerlimit is the requested output power + permissable Grid consumption factoring in the efficiency factor + newPowerLimit += _rp.output_power + config.Huawei.Auto_Power_Target_Power_Consumption / efficiency; + if (verboseLogging){ MessageOutput.printf("[HuaweiCanClass::loop] newPowerLimit: %f, output_power: %f \r\n", newPowerLimit, _rp.output_power); } @@ -424,7 +428,6 @@ void HuaweiCanClass::loop() } // Calculate output current - float efficiency = (_rp.efficiency > 0.5 ? _rp.efficiency : 1.0); float calculatedCurrent = efficiency * (newPowerLimit / _rp.output_voltage); // Limit output current to value requested by BMS diff --git a/src/WebApi_Huawei.cpp b/src/WebApi_Huawei.cpp index 61d88bfd9..594243b5c 100644 --- a/src/WebApi_Huawei.cpp +++ b/src/WebApi_Huawei.cpp @@ -196,6 +196,7 @@ void WebApiHuaweiClass::onAdminGet(AsyncWebServerRequest* request) root["lower_power_limit"] = config.Huawei.Auto_Power_Lower_Power_Limit; root["upper_power_limit"] = config.Huawei.Auto_Power_Upper_Power_Limit; root["stop_batterysoc_threshold"] = config.Huawei.Auto_Power_Stop_BatterySoC_Threshold; + root["target_power_consumption"] = config.Huawei.Auto_Power_Target_Power_Consumption; response->setLength(); request->send(response); @@ -266,6 +267,8 @@ void WebApiHuaweiClass::onAdminPost(AsyncWebServerRequest* request) config.Huawei.Auto_Power_Lower_Power_Limit = root["lower_power_limit"].as(); config.Huawei.Auto_Power_Upper_Power_Limit = root["upper_power_limit"].as(); config.Huawei.Auto_Power_Stop_BatterySoC_Threshold = root["stop_batterysoc_threshold"]; + config.Huawei.Auto_Power_Target_Power_Consumption = root["target_power_consumption"]; + WebApi.writeConfig(retMsg); response->setLength(); diff --git a/webapp/src/locales/de.json b/webapp/src/locales/de.json index 882bf40c9..00760d0e1 100644 --- a/webapp/src/locales/de.json +++ b/webapp/src/locales/de.json @@ -852,13 +852,15 @@ "enableVoltageLimit": "Start Spannungslimit", "stopVoltageLimitHint": "Maximal Spannung des Ladegeräts. Entspricht der geünschten Ladeschlussspannung der Batterie. Verwendet für die Automatische Leistungssteuerung und beim Notfallladen", "enableVoltageLimitHint": "Die automatische Leistungssteuerung wird deaktiviert wenn die Ausgangsspannung über diesem Wert liegt und wenn gleichzeitig die Ausgangsleistung unter die minimale Leistung fällt.\nDie automatische Leistungssteuerung wird re-aktiveiert wenn die Batteriespannung unter diesen Wert fällt.", - "maxPowerLimitHint": "Maximale Ausgangsleistung. Verwendet für die Automatische Leistungssteuerung und beim Notfallladen", + "upperPowerLimitHint": "Maximale Ausgangsleistung. Verwendet für die Automatische Leistungssteuerung und beim Notfallladen", "lowerPowerLimit": "Minimale Leistung", "upperPowerLimit": "Maximale Leistung", "StopBatterySoCThreshold": "Laden bei SoC beenden", "StopBatterySoCThresholdHint": "Zur Verlängerung der Akku-Lebensdauer kann der Ladevorgang bei einem bestimmten SoC gestoppt werden.\nHinweis: Manche LiFePO-Akkus müssen gelegentlich voll geladen werden, um die SoC-Anzeige akkurat zu halten.", "Seconds": "@:base.Seconds", - "EnableEmergencyCharge": "Notfallladen: Batterie wird mit maximaler Leistung geladen wenn durch das Batterie BMS angefordert" + "EnableEmergencyCharge": "Notfallladen: Batterie wird mit maximaler Leistung geladen wenn durch das Batterie BMS angefordert", + "targetPowerConsumption": "Angestrebter Netzbezug", + "targetPowerConsumptionHint": "Bei postiven Werten wird die eingestellte Leistung aus dem Stromnetz bezogen. Bei negativen Werten wird das Netzteil vorzeitig abgeschaltet." }, "battery": { "battery": "Batterie", diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 21dfc81f5..475dc3cd7 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -859,13 +859,15 @@ "enableVoltageLimit": "Re-enable voltage limit", "stopVoltageLimitHint": "Maximum charger voltage. Equals battery charge voltage limit. Used for automatic power control and when emergency charging", "enableVoltageLimitHint": "Automatic power control is disabled if the output voltage is higher then this value and if the output power drops below the minimum output power limit (set below).\nAutomatic power control is re-enabled if the battery voltage drops below the value set in this field.", - "maxPowerLimitHint": "Maximum output power. Used for automatic power control and when emergency charging", + "upperPowerLimitHint": "Maximum output power. Used for automatic power control and when emergency charging", "lowerPowerLimit": "Minimum output power", "upperPowerLimit": "Maximum output power", "StopBatterySoCThreshold": "Stop charging at SoC", "StopBatterySoCThresholdHint": "To prolong the battery's lifespan, charging can be stopped at a certain SoC level.\nHint: In order to keep the SoC reading accurate, some LiFePO cells must be charged to full capacity regularly.", "Seconds": "@:base.Seconds", - "EnableEmergencyCharge": "Emergency charge. Battery charged with maximum power if requested by Battery BMS" + "EnableEmergencyCharge": "Emergency charge. Battery charged with maximum power if requested by Battery BMS", + "targetPowerConsumption": "Target power consumption", + "targetPowerConsumptionHint": "Postitive values use grid power to charge the battery. Negative values result in early shutdown" }, "battery": { "battery": "Battery", diff --git a/webapp/src/locales/fr.json b/webapp/src/locales/fr.json index ae888850f..2cbc86f4b 100644 --- a/webapp/src/locales/fr.json +++ b/webapp/src/locales/fr.json @@ -847,13 +847,15 @@ "enableVoltageLimit": "Re-enable voltage limit", "stopVoltageLimitHint": "Maximum charger voltage. Equals battery charge voltage limit. Used for automatic power control and when emergency charging", "enableVoltageLimitHint": "Automatic power control is disabled if the output voltage is higher then this value and if the output power drops below the minimum output power limit (set below).\nAutomatic power control is re-enabled if the battery voltage drops below the value set in this field.", - "maxPowerLimitHint": "Maximum output power. Used for automatic power control and when emergency charging", + "upperPowerLimitHint": "Maximum output power. Used for automatic power control and when emergency charging", "lowerPowerLimit": "Minimum output power", "upperPowerLimit": "Maximum output power", "StopBatterySoCThreshold": "Stop charging at SoC", "StopBatterySoCThresholdHint": "To prolong the battery's lifespan, charging can be stopped at a certain SoC level.\nHint: In order to keep the SoC reading accurate, some LiFePO cells must be charged to full capacity regularly.", "Seconds": "@:base.Seconds", - "EnableEmergencyCharge": "Emergency charge. Battery charged with maximum power if requested by Battery BMS" + "EnableEmergencyCharge": "Emergency charge. Battery charged with maximum power if requested by Battery BMS", + "targetPowerConsumption": "Target power consumption", + "targetPowerConsumptionHint": "Postitive values use grid power to charge the battery. Negative values result in early shutdown" }, "battery": { "battery": "Battery", diff --git a/webapp/src/types/AcChargerConfig.ts b/webapp/src/types/AcChargerConfig.ts index 9dce2f874..80625d8e1 100644 --- a/webapp/src/types/AcChargerConfig.ts +++ b/webapp/src/types/AcChargerConfig.ts @@ -10,4 +10,5 @@ export interface AcChargerConfig { upper_power_limit: number; emergency_charge_enabled: boolean; stop_batterysoc_threshold: number; + target_power_consumption: number; } diff --git a/webapp/src/views/AcChargerAdminView.vue b/webapp/src/views/AcChargerAdminView.vue index 1feac505c..fb2ffe58f 100644 --- a/webapp/src/views/AcChargerAdminView.vue +++ b/webapp/src/views/AcChargerAdminView.vue @@ -78,16 +78,28 @@
+ aria-describedby="upperPowerLimitDescription" min="100" max="3000" required/> W
+ +
+
+ + W +
+
+