Skip to content

Commit fc3be70

Browse files
committed
Fix target current calcuation by taking actual charging mode into account
1 parent 4c23924 commit fc3be70

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/loadpoint.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,14 @@ func (lp *LoadPoint) detectPhases() {
297297
// maxCurrent calculates the maximum target current for PV mode
298298
func (lp *LoadPoint) maxCurrent(mode api.ChargeMode, sitePower float64) int64 {
299299
// calculate target charge current from delta power and actual current
300+
effectiveCurrent := lp.handler.TargetCurrent()
301+
if lp.status != api.StatusC {
302+
effectiveCurrent = 0
303+
}
300304
deltaCurrent := powerToCurrent(-sitePower, lp.Phases)
301-
targetCurrent := clamp(lp.handler.TargetCurrent()+deltaCurrent, 0, lp.MaxCurrent)
305+
targetCurrent := clamp(effectiveCurrent+deltaCurrent, 0, lp.MaxCurrent)
302306

303-
lp.log.DEBUG.Printf("max charge current: %dA = %dA + %dA (%.0fW @ %dp)", targetCurrent, lp.handler.TargetCurrent(), deltaCurrent, sitePower, lp.Phases)
307+
lp.log.DEBUG.Printf("max charge current: %dA = %dA + %dA (%.0fW @ %dp)", targetCurrent, effectiveCurrent, deltaCurrent, sitePower, lp.Phases)
304308

305309
// in MinPV mode return at least minCurrent
306310
if mode == api.ModeMinPV && targetCurrent < lp.MinCurrent {

0 commit comments

Comments
 (0)