From 7d3619f8f7a5346beabd2c1dc1867b9bf877e06d Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 3 Nov 2022 16:00:27 +0100 Subject: [PATCH] Sessions: fix session energy nulled when charger already disconnected --- core/db/session.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/db/session.go b/core/db/session.go index 3167dcf28..180caab7d 100644 --- a/core/db/session.go +++ b/core/db/session.go @@ -30,7 +30,9 @@ type Session struct { // Stop stops charging session with end meter reading and due total amount func (t *Session) Stop(chargedWh, total float64) { - t.ChargedEnergy = chargedWh / 1e3 + if chargedEnergy := chargedWh / 1e3; chargedEnergy > t.ChargedEnergy { + t.ChargedEnergy = chargedEnergy + } t.MeterStop = total t.Finished = time.Now() }