diff --git a/core/loadpoint.go b/core/loadpoint.go index 1afee984e..ba2be0bc9 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -1,6 +1,7 @@ package core import ( + "math" "sort" "sync" "time" @@ -585,7 +586,7 @@ func (lp *LoadPoint) publishSoC() { if lp.SoC.AlwaysUpdate || lp.connected() { f, err := lp.socEstimator.SoC(lp.chargedEnergy) if err == nil { - lp.socCharge = f + lp.socCharge = math.Trunc(f) lp.log.DEBUG.Printf("vehicle soc: %.0f%%", lp.socCharge) lp.publish("socCharge", lp.socCharge) diff --git a/core/wrapper/socestimator_test.go b/core/wrapper/socestimator_test.go index c402358e0..d74e7930e 100644 --- a/core/wrapper/socestimator_test.go +++ b/core/wrapper/socestimator_test.go @@ -57,7 +57,7 @@ func TestSoCEstimation(t *testing.T) { {8200, 80.0, 80.0}, {0, 25.0, 25.0}, {2500, 25.0, 50.0}, - {-10000, 50.0, 50.0}, + {0, 50.0, 50.0}, // -10000 {4990, 50.0, 99.9}, {5000, 50.0, 100.0}, {5001, 50.0, 100.0},