Fix target current calcuation by taking actual charging mode into account
This commit is contained in:
parent
4c23924cb2
commit
fc3be70251
1 changed files with 6 additions and 2 deletions
|
|
@ -297,10 +297,14 @@ func (lp *LoadPoint) detectPhases() {
|
|||
// maxCurrent calculates the maximum target current for PV mode
|
||||
func (lp *LoadPoint) maxCurrent(mode api.ChargeMode, sitePower float64) int64 {
|
||||
// calculate target charge current from delta power and actual current
|
||||
effectiveCurrent := lp.handler.TargetCurrent()
|
||||
if lp.status != api.StatusC {
|
||||
effectiveCurrent = 0
|
||||
}
|
||||
deltaCurrent := powerToCurrent(-sitePower, lp.Phases)
|
||||
targetCurrent := clamp(lp.handler.TargetCurrent()+deltaCurrent, 0, lp.MaxCurrent)
|
||||
targetCurrent := clamp(effectiveCurrent+deltaCurrent, 0, lp.MaxCurrent)
|
||||
|
||||
lp.log.DEBUG.Printf("max charge current: %dA = %dA + %dA (%.0fW @ %dp)", targetCurrent, lp.handler.TargetCurrent(), deltaCurrent, sitePower, lp.Phases)
|
||||
lp.log.DEBUG.Printf("max charge current: %dA = %dA + %dA (%.0fW @ %dp)", targetCurrent, effectiveCurrent, deltaCurrent, sitePower, lp.Phases)
|
||||
|
||||
// in MinPV mode return at least minCurrent
|
||||
if mode == api.ModeMinPV && targetCurrent < lp.MinCurrent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue