@@ -178,7 +178,7 @@ func testScale(t *testing.T, lp *Loadpoint, sitePower float64, direction string,
178178 // scale-up should only execute when the 1p max current is exceeded
179179 // we're testing this here and remove the upscale expectation for the following test below 1p max current
180180 if maxAmp := - sitePower / Voltage ; maxAmp < maxA {
181- if scaled := lp .pvScalePhases (sitePower , minA , maxAmp - 0.0001 ); scaled != 3 {
181+ if scaled := lp .pvScalePhases (sitePower , minA , maxAmp - 0.0001 , true ); scaled != 3 {
182182 t .Errorf ("%v act=%d max=%d missing scale %s at reduced max current %.1fA" , tc , act , max , direction , maxAmp )
183183 }
184184
@@ -187,7 +187,7 @@ func testScale(t *testing.T, lp *Loadpoint, sitePower float64, direction string,
187187 }
188188 }
189189
190- scaled := lp .pvScalePhases (sitePower , minA , maxA )
190+ scaled := lp .pvScalePhases (sitePower , minA , maxA , true )
191191
192192 if strings .Contains (testExpectation , testDirection ) {
193193 if scaled == 0 {
@@ -384,6 +384,13 @@ func TestPvScalePhasesTimer(t *testing.T) {
384384 lp .chargePower = 3 * Voltage * minA
385385 }},
386386
387+ // minpv never disables, so scale down even if 1p is not sustainable (#33208)
388+ {"3/3->1, insufficient for 1p, charging, minpv" , 3 , 3 , 0.1 , 1 , 1 , func (lp * Loadpoint ) {
389+ lp .phaseTimer = elapsed
390+ lp .enabled = true
391+ lp .mode = api .ModeMinPV
392+ }},
393+
387394 // switch down from 3p/0p while not yet charging
388395 {"3/0->1, not enough power, not charging" , 3 , 0 , 0 , 1 , 1 , func (lp * Loadpoint ) {
389396 lp .status = api .StatusB
@@ -437,7 +444,7 @@ func TestPvScalePhasesTimer(t *testing.T) {
437444 charger .MockPhaseSwitcher .EXPECT ().Phases1p3p (tc .toPhases ).Return (nil )
438445 }
439446
440- res := lp .pvScalePhases (tc .sitePower , minA , maxA )
447+ res := lp .pvScalePhases (tc .sitePower , minA , maxA , lp . mode != api . ModeMinPV )
441448
442449 require .Equal (t , tc .res , res , tc .desc )
443450 require .Equal (t , tc .toPhases , lp .phases , tc .desc )
@@ -785,7 +792,7 @@ func TestPvScalePhasesCircuitLimits(t *testing.T) {
785792 }{plainCharger , phaseCharger },
786793 }
787794
788- require .Equal (t , tc .expectedPhases , lp .pvScalePhases (tc .sitePower , lp .minCurrent , lp .maxCurrent ))
795+ require .Equal (t , tc .expectedPhases , lp .pvScalePhases (tc .sitePower , lp .minCurrent , lp .maxCurrent , true ))
789796
790797 ctrl .Finish ()
791798 })
0 commit comments