Gracefully handle start with unknown phases configuration (#2526)
This commit is contained in:
parent
6a768f010b
commit
4340fa7d64
1 changed files with 15 additions and 8 deletions
|
|
@ -1079,8 +1079,15 @@ func (lp *LoadPoint) pvScalePhases(availablePower, minCurrent, maxCurrent float6
|
|||
lp.log.WARN.Printf("ignoring inconsistent phases: %dp < %dp observed active", phases, lp.activePhases)
|
||||
}
|
||||
|
||||
// this can happen the first time for a 1p3p-capable charger, see https://github.com/evcc-io/evcc/issues/2520
|
||||
if phases == 0 && lp.activePhases == 0 {
|
||||
lp.log.DEBUG.Printf("assuming initial phase state: 3p")
|
||||
lp.phaseTimer = elapsed
|
||||
lp.activePhases = 3
|
||||
}
|
||||
|
||||
var waiting bool
|
||||
targetCurrent := availablePower / Voltage / float64(lp.activePhases)
|
||||
targetCurrent := powerToCurrent(availablePower, lp.activePhases)
|
||||
|
||||
// scale down phases
|
||||
if targetCurrent < minCurrent && (phases == 0 || phases == 3) && lp.activePhases > 1 {
|
||||
|
|
@ -1172,13 +1179,6 @@ func (lp *LoadPoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
|
|||
minCurrent := lp.GetMinCurrent()
|
||||
maxCurrent := lp.GetMaxCurrent()
|
||||
|
||||
// calculate target charge current from delta power and actual current
|
||||
effectiveCurrent := lp.effectiveCurrent()
|
||||
deltaCurrent := powerToCurrent(-sitePower, lp.activePhases)
|
||||
targetCurrent := math.Max(effectiveCurrent+deltaCurrent, 0)
|
||||
|
||||
lp.log.DEBUG.Printf("max charge current: %.3gA = %.3gA + %.3gA (%.0fW @ %dp)", targetCurrent, effectiveCurrent, deltaCurrent, sitePower, lp.activePhases)
|
||||
|
||||
// switch phases up/down
|
||||
if _, ok := lp.charger.(api.ChargePhases); ok {
|
||||
availablePower := -sitePower + lp.chargePower
|
||||
|
|
@ -1189,6 +1189,13 @@ func (lp *LoadPoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
|
|||
}
|
||||
}
|
||||
|
||||
// calculate target charge current from delta power and actual current
|
||||
effectiveCurrent := lp.effectiveCurrent()
|
||||
deltaCurrent := powerToCurrent(-sitePower, lp.activePhases)
|
||||
targetCurrent := math.Max(effectiveCurrent+deltaCurrent, 0)
|
||||
|
||||
lp.log.DEBUG.Printf("max charge current: %.3gA = %.3gA + %.3gA (%.0fW @ %dp)", targetCurrent, effectiveCurrent, deltaCurrent, sitePower, lp.activePhases)
|
||||
|
||||
// in MinPV mode or under special conditions return at least minCurrent
|
||||
if (mode == api.ModeMinPV || batteryBuffered || lp.climateActive()) && targetCurrent < minCurrent {
|
||||
return minCurrent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue