From c8e1d25e75a698a848c02473c67fb34f82dae7a3 Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 15 Aug 2020 13:41:42 +0200 Subject: [PATCH] Fix phase detection not scaling back up --- core/loadpoint.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 3893c41d6..4af133240 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -416,20 +416,21 @@ func (lp *LoadPoint) detectPhases() { return } - lp.log.TRACE.Printf("charge currents: %vA", []float64{i1, i2, i3}) - lp.publish("chargeCurrents", []float64{i1, i2, i3}) + currents := []float64{i1, i2, i3} + lp.log.TRACE.Printf("charge currents: %vA", currents) + lp.publish("chargeCurrents", currents) if lp.charging { var phases int64 - for _, i := range []float64{i1, i2, i3} { + for _, i := range currents { if i >= minActiveCurrent { phases++ } } if phases > 0 { - lp.Phases = min(phases, lp.Phases) - lp.log.DEBUG.Printf("detected phases: %d (%v)", lp.Phases, []float64{i1, i2, i3}) + lp.Phases = phases + lp.log.DEBUG.Printf("detected phases: %dp %vA", lp.Phases, currents) lp.publish("activePhases", lp.Phases) }