Tibber: recover from disconnect (#18504)
This commit is contained in:
parent
31e476cdaa
commit
1bfcc19f0d
1 changed files with 13 additions and 2 deletions
|
|
@ -120,8 +120,19 @@ func NewTibberFromConfig(ctx context.Context, other map[string]interface{}) (api
|
|||
}()
|
||||
|
||||
go func() {
|
||||
if err := client.Run(); err != nil {
|
||||
log.ERROR.Println(err)
|
||||
// The pulse sometimes declines valid(!) subscription requests, and asks the client to disconnect.
|
||||
// Therefore we need to restart the client when exiting gracefully upon server request
|
||||
// https://github.com/evcc-io/evcc/issues/17925#issuecomment-2621458890
|
||||
for tick := time.Tick(10 * time.Second); ; {
|
||||
if err := client.Run(); err != nil {
|
||||
log.ERROR.Println(err)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-tick:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue