MCPcopy Create free account
hub / github.com/evcc-io/evcc / stopSession

Method stopSession

core/loadpoint_session.go:87–104  ·  view source on GitHub ↗

stopSession ends a charging session segment and persists the session.

()

Source from the content-addressed store, hash-verified

85
86// stopSession ends a charging session segment and persists the session.
87func (lp *Loadpoint) stopSession() {
88 s := lp.session
89
90 // test guard
91 if lp.db == nil || s == nil {
92 return
93 }
94
95 // abort the session if charging has never started
96 if s.Created.IsZero() {
97 return
98 }
99
100 s.Finished = lp.clock.Now()
101 s.ChargeDuration = new(lp.chargeDuration.Abs())
102
103 lp.applyEnergyMetrics(s)
104}
105
106type sessionOption func(*session.Session)
107

Callers 5

evChargeStopHandlerMethod · 0.95
resetHeatingSessionMethod · 0.95
TestSessionFunction · 0.95
TestResetHeatingSessionFunction · 0.95

Calls 2

applyEnergyMetricsMethod · 0.95
IsZeroMethod · 0.45

Tested by 3

TestSessionFunction · 0.76
TestResetHeatingSessionFunction · 0.76