Allow grace period before out of sync error is displayed (#2937)

This commit is contained in:
andig 2022-03-23 17:16:02 +01:00 • committed by GitHub
parent 1217da8504
commit 515cd5f810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,8 @@ const (
minActiveCurrent = 1.0 // minimum current at which a phase is treated as active
vehicleDetectInterval = 3 * time.Minute
vehicleDetectDuration = 10 * time.Minute
guardGracePeriod = 10 * time.Second // allow out of sync during this timespan
)
// elapsed is the time an expired timer will be set to
@ -563,7 +565,9 @@ func (lp *LoadPoint) syncCharger() {
enabled, err := lp.charger.Enabled()
if err == nil {
if enabled != lp.enabled {
lp.log.WARN.Printf("charger out of sync: expected %vd, got %vd", status[lp.enabled], status[enabled])
if time.Since(lp.guardUpdated) > guardGracePeriod {
lp.log.WARN.Printf("charger out of sync: expected %vd, got %vd", status[lp.enabled], status[enabled])
}
err = lp.charger.Enable(lp.enabled)
}