From b007b9bebdc653505e6935480a0f929d4ae9d191 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 14 Jan 2022 17:55:37 +0100 Subject: [PATCH] Fix charging doesn't restart after 1p3p switch (#2293) --- core/loadpoint.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index ac1a075ec..7b7027bf1 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -48,6 +48,9 @@ const ( settleDuration = 100 * time.Millisecond ) +// elapsed is the time an expired timer will be set to +var elapsed = time.Unix(0, 1) + // PollConfig defines the vehicle polling mode and interval type PollConfig struct { Mode string `mapstructure:"mode"` // polling mode charging (default), connected, always @@ -350,7 +353,10 @@ func (lp *LoadPoint) evChargeStopHandler() { lp.socUpdated = time.Time{} // reset pv enable/disable timer - lp.resetPVTimerIfRunning() + // https://github.com/evcc-io/evcc/issues/2289 + if !lp.pvTimer.Equal(elapsed) { + lp.resetPVTimerIfRunning() + } } // evVehicleConnectHandler sends external start event @@ -879,8 +885,11 @@ func (lp *LoadPoint) effectiveCurrent() float64 { // elapsePVTimer puts the pv enable/disable timer into elapsed state func (lp *LoadPoint) elapsePVTimer() { - lp.pvTimer = lp.clock.Now().Add(-lp.Disable.Delay) - lp.guardUpdated = lp.clock.Now().Add(-lp.GuardDuration) + lp.log.DEBUG.Printf("pv timer elapse") + + lp.pvTimer = elapsed + lp.guardUpdated = elapsed + lp.publishTimer(pvTimer, 0, timerInactive) }