diff --git a/core/loadpoint.go b/core/loadpoint.go index 667a8730c..c359746db 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -1231,11 +1231,22 @@ func (lp *Loadpoint) scalePhases(phases int) error { // fastCharging scales to 3p if available and sets maximum current func (lp *Loadpoint) fastCharging() error { - err := lp.scalePhasesIfAvailable(3) - if err == nil { - err = lp.setLimit(lp.effectiveMaxCurrent()) + if lp.hasPhaseSwitching() { + phases := 3 + maxPower1p := Voltage * lp.effectiveMaxCurrent() + + // load management limit active + if circuitMaxPower := lp.circuitMaxPower(); circuitMaxPower < 1.1*maxPower1p { + phases = 1 + lp.log.DEBUG.Printf("fast charging: scaled to 1p to match %.0fW max circuit power", circuitMaxPower) + } + + if err := lp.scalePhasesIfAvailable(phases); err != nil { + return err + } } - return err + + return lp.setLimit(lp.effectiveMaxCurrent()) } // pvScalePhases switches phases if necessary and returns number of phases switched to diff --git a/core/loadpoint_effective.go b/core/loadpoint_effective.go index b38982ffd..404bc8002 100644 --- a/core/loadpoint_effective.go +++ b/core/loadpoint_effective.go @@ -217,21 +217,25 @@ func (lp *Loadpoint) EffectiveMinPower() float64 { return Voltage * lp.effectiveMinCurrent() * float64(lp.minActivePhases()) } +func (lp *Loadpoint) circuitMaxPower() float64 { + if lp.circuit == nil { + return 0 + } + + return lp.circuit.GetMaxPower() +} + // EffectiveMaxPower returns the effective max power taking vehicle capabilities, // phase scaling and load management power limits into account func (lp *Loadpoint) EffectiveMaxPower() float64 { lp.RLock() defer lp.RUnlock() - res := lp.effectiveMaxPower() - - if lp.circuit != nil { - if v := lp.circuit.GetMaxPower(); v > 0 { - res = min(res, v) - } + if circuitMaxPower := lp.circuitMaxPower(); circuitMaxPower > 0 { + return min(lp.effectiveMaxPower(), circuitMaxPower) } - return res + return lp.effectiveMaxPower() } // effectiveMaxPower returns the effective max power taking vehicle capabilities and phase scaling into account