Loadpoint: allow fast charging to switch phases (#23571)

This commit is contained in:
andig 2025-09-21 12:28:03 +02:00 • committed by GitHub
parent 2f0c720b49
commit d2549d7892
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 11 deletions

View file

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

View file

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