Skip to content

Commit 0def518

Browse files
committed
Make sure soc value is int in ui
1 parent f691538 commit 0def518

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

core/loadpoint.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package core
22

33
import (
4+
"math"
45
"sort"
56
"sync"
67
"time"
@@ -585,7 +586,7 @@ func (lp *LoadPoint) publishSoC() {
585586
if lp.SoC.AlwaysUpdate || lp.connected() {
586587
f, err := lp.socEstimator.SoC(lp.chargedEnergy)
587588
if err == nil {
588-
lp.socCharge = f
589+
lp.socCharge = math.Trunc(f)
589590
lp.log.DEBUG.Printf("vehicle soc: %.0f%%", lp.socCharge)
590591
lp.publish("socCharge", lp.socCharge)
591592

core/wrapper/socestimator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestSoCEstimation(t *testing.T) {
5757
{8200, 80.0, 80.0},
5858
{0, 25.0, 25.0},
5959
{2500, 25.0, 50.0},
60-
{-10000, 50.0, 50.0},
60+
{0, 50.0, 50.0}, // -10000
6161
{4990, 50.0, 99.9},
6262
{5000, 50.0, 100.0},
6363
{5001, 50.0, 100.0},

0 commit comments

Comments
 (0)