Make sure soc value is int in ui

This commit is contained in:
andig 2020-08-17 13:41:56 +02:00
parent f691538660
commit 0def518b21
2 changed files with 3 additions and 2 deletions

View file

@ -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)

View file

@ -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},