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

Method applyEnergyMetrics

core/loadpoint_session.go:68–84  ·  view source on GitHub ↗

applyEnergyMetrics writes current energy metrics into the session and persists it.

(s *session.Session)

Source from the content-addressed store, hash-verified

66
67// applyEnergyMetrics writes current energy metrics into the session and persists it.
68func (lp *Loadpoint) applyEnergyMetrics(s *session.Session) {
69 if meterStop := lp.chargeMeterTotal(); meterStop > 0 {
70 s.MeterStop = &meterStop
71 }
72
73 if soc := lp.vehicleSoc; soc > 0 && !lp.chargerHasFeature(api.Heating) {
74 s.SocEnd = &soc
75 }
76
77 s.SolarPercentage = new(lp.energyMetrics.SolarPercentage())
78 s.Price = lp.energyMetrics.Price()
79 s.PricePerKWh = lp.energyMetrics.PricePerKWh()
80 s.Co2PerKWh = lp.energyMetrics.Co2PerKWh()
81 s.ChargedEnergy = lp.energyMetrics.TotalWh() / 1e3
82
83 lp.db.Persist(s)
84}
85
86// stopSession ends a charging session segment and persists the session.
87func (lp *Loadpoint) stopSession() {

Callers 2

stopSessionMethod · 0.95
finalizeSessionEnergyMethod · 0.95

Calls 8

chargeMeterTotalMethod · 0.95
chargerHasFeatureMethod · 0.95
SolarPercentageMethod · 0.80
PriceMethod · 0.80
PricePerKWhMethod · 0.80
Co2PerKWhMethod · 0.80
TotalWhMethod · 0.80
PersistMethod · 0.80

Tested by

no test coverage detected