diff --git a/core/wrapper/socestimator.go b/core/wrapper/socestimator.go index 64caf1774..898b99d40 100644 --- a/core/wrapper/socestimator.go +++ b/core/wrapper/socestimator.go @@ -111,7 +111,8 @@ func (s *SocEstimator) SoC(chargedEnergy float64) (float64, error) { if socDelta != 0 || energyDelta < 0 { // soc value change or unexpected energy reset // calculate gradient, wh per soc % - if socDelta > 1 && energyDelta > 0 && s.prevSoC > 0 { + // TODO: drop samples with unmatching state of evse and vehicle + if socDelta > 2 && energyDelta > 0 && s.prevSoC > 0 { s.energyPerSocStep = energyDelta / socDelta s.virtualCapacity = s.energyPerSocStep * 100 s.log.TRACE.Printf("soc gradient updated: energyPerSocStep: %0.0fWh, virtualCapacity: %0.0fWh", s.energyPerSocStep, s.virtualCapacity) diff --git a/core/wrapper/socestimator_test.go b/core/wrapper/socestimator_test.go index 2e61de649..6bf058a11 100644 --- a/core/wrapper/socestimator_test.go +++ b/core/wrapper/socestimator_test.go @@ -58,7 +58,7 @@ func TestSoCEstimation(t *testing.T) { {7100, 71.0, 71.0, 10000}, {7300, 72.0, 72.0, 10000}, {7400, 73.0, 73.0, 10000}, - {7700, 75.0, 75.0, 15000}, // 0.3kWh add 2% -> 15kWh battery + {7700, 75.0, 75.0, 10000}, {8200, 80.0, 80.0, 10000}, {0, 25.0, 25.0, 10000}, {2500, 25.0, 50.0, 10000},