Skip to content

Commit 4c23924

Browse files
committed
Improve log messages and round durations to second accuracy
1 parent 7c864df commit 4c23924

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/loadpoint.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (lp *LoadPoint) maxCurrent(mode api.ChargeMode, sitePower float64) int64 {
324324
if mode == api.ModePV && enabled && targetCurrent < lp.MinCurrent {
325325
// kick off disable sequence
326326
if sitePower >= lp.Disable.Threshold {
327-
lp.log.DEBUG.Printf("site power %.0f >= disable threshold %.0f", sitePower, lp.Disable.Threshold)
327+
lp.log.DEBUG.Printf("site power %.0fW >= disable threshold %.0fW", sitePower, lp.Disable.Threshold)
328328

329329
if lp.pvTimer.IsZero() {
330330
lp.log.DEBUG.Println("start pv disable timer")
@@ -347,7 +347,7 @@ func (lp *LoadPoint) maxCurrent(mode api.ChargeMode, sitePower float64) int64 {
347347
// kick off enable sequence
348348
if targetCurrent >= lp.MinCurrent ||
349349
(lp.Enable.Threshold != 0 && sitePower <= lp.Enable.Threshold) {
350-
lp.log.DEBUG.Printf("site power %.0f < enable threshold %.0f", sitePower, lp.Enable.Threshold)
350+
lp.log.DEBUG.Printf("site power %.0fW < enable threshold %.0fW", sitePower, lp.Enable.Threshold)
351351

352352
if lp.pvTimer.IsZero() {
353353
lp.log.DEBUG.Println("start pv enable timer")
@@ -401,7 +401,7 @@ func (lp *LoadPoint) chargeDuration() time.Duration {
401401
lp.log.ERROR.Printf("charge timer error: %v", err)
402402
return 0
403403
}
404-
return d
404+
return d.Round(time.Second)
405405
}
406406

407407
// chargedEnergy returns energy consumption since charge start in kWh
@@ -428,7 +428,7 @@ func (lp *LoadPoint) remainingChargeDuration(chargePercent float64) time.Duratio
428428

429429
if lp.chargePower > 0 && lp.vehicle != nil {
430430
whRemaining := (1 - chargePercent/100.0) * 1e3 * float64(lp.vehicle.Capacity())
431-
return time.Duration(float64(time.Hour) * whRemaining / lp.chargePower)
431+
return time.Duration(float64(time.Hour) * whRemaining / lp.chargePower).Round(time.Second)
432432
}
433433

434434
return -1

0 commit comments

Comments
 (0)