Skip to content

Commit

Permalink
Awattar: fetch more than 24h price data (#16338)
Browse files Browse the repository at this point in the history
  • Loading branch information
andi0b authored Sep 27, 2024
1 parent d53ead0 commit 4af2d19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tariff/awattar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand Down

0 comments on commit 4af2d19

Please sign in to comment.