Skip to content

Commit

Permalink
Hardybarth Salia: ignore hearbeat errors up to one minute (evcc-io#8074)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored May 19, 2023
1 parent 8bf08f2 commit cf53944
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 8 additions & 1 deletion charger/hardybarth-salia.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/charger/echarge"
"github.com/evcc-io/evcc/charger/echarge/salia"
Expand Down Expand Up @@ -116,8 +117,14 @@ 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

for ; true; <-time.Tick(30 * time.Second) {
if err := wb.post(salia.HeartBeat, "alive"); err != nil {
if err := backoff.Retry(func() error {
return wb.post(salia.HeartBeat, "alive")
}, bo); err != nil {
wb.log.ERROR.Println("heartbeat:", err)
}
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/basvdlei/gotsmart v0.0.3
github.com/benbjohnson/clock v1.3.4
github.com/bogosj/tesla v1.1.1-0.20230430222423-0d6e63ee90c9
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cenkalti/backoff/v4 v4.2.1
github.com/cjrd/allocate v0.0.0-20220510215731-986f24f0fb18
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/containrrr/shoutrrr v0.7.1
Expand Down Expand Up @@ -111,7 +111,6 @@ require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvF
github.com/bogosj/tesla v1.1.1-0.20230430222423-0d6e63ee90c9 h1:Wd6BCHLS720MX1s2WHvu5Y7lo3HvRC/qONo7VbEbuac=
github.com/bogosj/tesla v1.1.1-0.20230430222423-0d6e63ee90c9/go.mod h1:eF5996x0SVG6eslBpMA5kEjT1j9Q5gHO3lqovDmZKls=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
Expand Down
2 changes: 1 addition & 1 deletion meter/dsmr.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/basvdlei/gotsmart/crc16"
"github.com/basvdlei/gotsmart/dsmr"
"github.com/cenkalti/backoff"
"github.com/cenkalti/backoff/v4"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
Expand Down

0 comments on commit cf53944

Please sign in to comment.