diff --git a/charger/easee.go b/charger/easee.go index 941925f86..8c085c08f 100644 --- a/charger/easee.go +++ b/charger/easee.go @@ -207,7 +207,7 @@ func (c *Easee) chargerSite(charger string) (easee.Site, error) { // connect creates an HTTP connection to the signalR hub func (c *Easee) connect(ts oauth2.TokenSource) func() (signalr.Connection, error) { bo := backoff.NewExponentialBackOff() - bo.MaxElapsedTime = time.Minute + bo.MaxInterval = time.Minute return func() (conn signalr.Connection, err error) { defer func() { @@ -447,7 +447,7 @@ func (c *Easee) inExpectedOpMode(enable bool) bool { c.mux.Lock() defer c.mux.Unlock() - //start/resume + // start/resume if enable { return c.opMode == easee.ModeCharging || c.opMode == easee.ModeCompleted || @@ -455,7 +455,7 @@ func (c *Easee) inExpectedOpMode(enable bool) bool { c.opMode == easee.ModeReadyToCharge } - //paused/stopped + // paused/stopped return c.opMode == easee.ModeAwaitingStart || c.opMode == easee.ModeAwaitingAuthentication } diff --git a/charger/hardybarth-salia.go b/charger/hardybarth-salia.go index 533247d56..7fe10e483 100644 --- a/charger/hardybarth-salia.go +++ b/charger/hardybarth-salia.go @@ -119,7 +119,7 @@ func NewSalia(uri string, cache time.Duration) (api.Charger, error) { func (wb *Salia) heartbeat() { bo := backoff.NewExponentialBackOff() bo.InitialInterval = 5 * time.Second - bo.MaxElapsedTime = time.Minute + bo.MaxInterval = time.Minute for range time.Tick(30 * time.Second) { if err := backoff.Retry(func() error { diff --git a/meter/dsmr.go b/meter/dsmr.go index 1e5324cfb..d7b4ee400 100644 --- a/meter/dsmr.go +++ b/meter/dsmr.go @@ -139,9 +139,8 @@ func NewDsmr(uri, energy string, timeout time.Duration) (api.Meter, error) { // based on https://github.com/basvdlei/gotsmart/blob/master/gotsmart.go func (m *Dsmr) run(conn net.Conn, done chan struct{}) { log := util.NewLogger("dsmr") - backoff := backoff.NewExponentialBackOff() - backoff.InitialInterval = time.Second - backoff.MaxInterval = 5 * time.Minute + bo := backoff.NewExponentialBackOff() + bo.MaxInterval = 5 * time.Minute handle := func(op string, err error) { log.ERROR.Printf("%s: %v", op, err) @@ -161,7 +160,7 @@ func (m *Dsmr) run(conn net.Conn, done chan struct{}) { conn, err = m.connect() if err != nil { handle("connect", err) - time.Sleep(backoff.NextBackOff().Truncate(time.Second)) + time.Sleep(bo.NextBackOff().Truncate(time.Second)) continue } @@ -169,7 +168,7 @@ func (m *Dsmr) run(conn net.Conn, done chan struct{}) { } if b, err := reader.Peek(1); err == nil { - backoff.Reset() + bo.Reset() if string(b) != "/" { log.DEBUG.Printf("ignoring garbage character: %c\n", b) @@ -178,7 +177,7 @@ func (m *Dsmr) run(conn net.Conn, done chan struct{}) { } } else { handle("peek", err) - time.Sleep(backoff.NextBackOff().Truncate(time.Second)) + time.Sleep(bo.NextBackOff().Truncate(time.Second)) continue } diff --git a/meter/rct.go b/meter/rct.go index 35bfaf638..ce3174408 100644 --- a/meter/rct.go +++ b/meter/rct.go @@ -83,8 +83,8 @@ func NewRCT(uri, usage string, cache time.Duration, capacity func() float64) (ap } bo := backoff.NewExponentialBackOff() - bo.MaxElapsedTime = time.Second bo.InitialInterval = 10 * time.Millisecond + bo.MaxInterval = time.Second m := &RCT{ usage: strings.ToLower(usage), diff --git a/tariff/helper.go b/tariff/helper.go index d20bfb3ab..2f9e0485f 100644 --- a/tariff/helper.go +++ b/tariff/helper.go @@ -8,7 +8,7 @@ import ( func newBackoff() backoff.BackOff { bo := backoff.NewExponentialBackOff() - bo.InitialInterval = 5 * time.Second - bo.MaxElapsedTime = time.Minute + bo.InitialInterval = time.Second + bo.MaxInterval = time.Minute return bo }