From b54aabb16f494a38a694580cceac8367e6f70315 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 24 Jan 2021 13:17:55 +0100 Subject: [PATCH] Fix invalid time displayed without sending message --- core/loadpoint.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 552bf0cb09..78b592f0ad 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -308,7 +308,7 @@ func (lp *LoadPoint) evVehicleConnectHandler() { // duration lp.connectedTime = lp.clock.Now() - lp.publish("connectedDuration", 0) + lp.publish("connectedDuration", time.Duration(0)) // soc estimation reset lp.socUpdated = time.Time{} @@ -616,6 +616,12 @@ func (lp *LoadPoint) updateChargerStatus() error { if prevStatus := lp.status; status != prevStatus { lp.status = status + // changed from empty (initial startup) - set connected without sending message + if prevStatus == api.StatusNone { + lp.connectedTime = lp.clock.Now() + lp.publish("connectedDuration", time.Duration(0)) + } + // changed from A - connected if prevStatus == api.StatusA { lp.bus.Publish(evVehicleConnect)