diff --git a/tariff/awattar.go b/tariff/awattar.go index 9acef9d67..bf9ce03aa 100644 --- a/tariff/awattar.go +++ b/tariff/awattar.go @@ -62,8 +62,14 @@ func (t *Awattar) run(done chan error) { for ; true; <-tick.C { var res awattar.Prices + // Awattar publishes prices for next day around 13:00 CET/CEST, so up to 35h of price data are available + // To be on the safe side request a window of -2h and +48h, the API doesn't mind requesting more than available + start := time.Now().Add(-2 * time.Hour).UnixMilli() + end := time.Now().Add(48 * time.Hour).UnixMilli() + uri := fmt.Sprintf("%s?start=%d&end=%d", t.uri, start, end) + if err := backoff.Retry(func() error { - return backoffPermanentError(client.GetJSON(t.uri, &res)) + return backoffPermanentError(client.GetJSON(uri, &res)) }, bo()); err != nil { once.Do(func() { done <- err })