From 1bfcc19f0db3f4c0c922c37ed76f17d7ab57f80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20He=C3=9F?= Date: Sat, 1 Feb 2025 14:21:46 +0100 Subject: [PATCH] Tibber: recover from disconnect (#18504) --- meter/tibber-pulse.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meter/tibber-pulse.go b/meter/tibber-pulse.go index 6e1f36bce..a94447626 100644 --- a/meter/tibber-pulse.go +++ b/meter/tibber-pulse.go @@ -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 + } } }()