diff --git a/shared/lib_battery.cpp b/shared/lib_battery.cpp index 284b2c64c..416af7c73 100644 --- a/shared/lib_battery.cpp +++ b/shared/lib_battery.cpp @@ -502,8 +502,8 @@ double battery_t::calculate_current_for_power_kw(double &P_kw) { if (P_kw < 0) { double max_P = calculate_max_charge_kw(¤t); if (max_P > P_kw) { - P_kw = max_P; - return current; + P_kw = -max_P; + return -current; } } else { double max_P = calculate_max_discharge_kw(¤t);