applyEnergyMetrics writes current energy metrics into the session and persists it.
(s *session.Session)
| 66 | |
| 67 | // applyEnergyMetrics writes current energy metrics into the session and persists it. |
| 68 | func (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. |
| 87 | func (lp *Loadpoint) stopSession() { |
no test coverage detected