Loadpoint: reset energy metrics when creating session (#22126)

This commit is contained in:
andig 2025-06-29 18:40:08 +02:00 • committed by GitHub
parent 01ae739413
commit 57f59ca703
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -473,11 +473,6 @@ func (lp *Loadpoint) evChargeStopHandler() {
func (lp *Loadpoint) evVehicleConnectHandler() {
lp.log.INFO.Printf("car connected")
// energy
lp.energyMetrics.Reset()
lp.energyMetrics.Publish("session", lp)
lp.publish(keys.ChargedEnergy, lp.GetChargedEnergy())
// duration
lp.connectedTime = lp.clock.Now()
lp.publish(keys.ConnectedDuration, time.Duration(0))

View file

@ -2,6 +2,7 @@ package core
import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/keys"
"github.com/evcc-io/evcc/core/session"
"github.com/jinzhu/now"
"github.com/samber/lo"
@ -45,6 +46,11 @@ func (lp *Loadpoint) createSession() {
lp.session.Identifier = id
}
}
// energy
lp.energyMetrics.Reset()
lp.energyMetrics.Publish("session", lp)
lp.publish(keys.ChargedEnergy, lp.GetChargedEnergy())
}
// stopSession ends a charging session segment and persists the session.