Use maximum possible phases for scale-up calculation (#2753)

This commit is contained in:
andig 2022-03-02 11:30:35 +01:00 • committed by GitHub
parent 6165a16055
commit 89efcb6e64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -1079,7 +1079,7 @@ func (lp *LoadPoint) pvScalePhases(availablePower, minCurrent, maxCurrent float6
scalable := maxPhases > 1 && phases < maxPhases
// scale up phases
if min3pCurrent := powerToCurrent(availablePower, 3); min3pCurrent >= minCurrent && scalable {
if min3pCurrent := powerToCurrent(availablePower, maxPhases); min3pCurrent >= minCurrent && scalable {
lp.log.DEBUG.Printf("available power %.0fW > %.0fW min %dp threshold", availablePower, 3*Voltage*minCurrent, maxPhases)
if lp.phaseTimer.IsZero() {

View file

@ -162,9 +162,12 @@ func TestPvScalePhases(t *testing.T) {
ctrl.Finish()
// scale up
min3p := 3 * minA * Voltage
min3p := float64(tc.maxExpected) * minA * Voltage
lp.phaseTimer = time.Time{}
lp.Phases = tc.physical // reset to initial state
// reset to initial state
lp.Phases = tc.physical
lp.measuredPhases = tc.measuredPhases
plainCharger.EXPECT().Enable(false).Return(nil).MaxTimes(1)
phaseCharger.EXPECT().Phases1p3p(3).Return(nil).MaxTimes(1)