Skip to content

Commit

Permalink
Amber: fix api query (#13196)
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-w authored Mar 29, 2024
1 parent 92884c2 commit 671a580
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tariff/amber.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewAmberFromConfig(other map[string]interface{}) (api.Tariff, error) {
embed: &cc.embed,
log: log,
Helper: request.NewHelper(log),
uri: fmt.Sprintf(amber.URI, strings.ToUpper(cc.SiteID), time.Now().AddDate(0, 0, 1).Format("2006-01-02")),
uri: fmt.Sprintf(amber.URI, strings.ToUpper(cc.SiteID)),
channel: strings.ToLower(cc.Channel),
data: util.NewMonitor[api.Rates](2 * time.Hour),
}
Expand All @@ -87,9 +87,10 @@ func (t *Amber) run(done chan error) {
tick := time.NewTicker(time.Minute)
for ; true; <-tick.C {
var res []amber.PriceInfo

uri := fmt.Sprintf("%s&endDate=%s", t.uri,
time.Now().AddDate(0, 0, 2).Format("2006-01-02"))
if err := backoff.Retry(func() error {
return t.GetJSON(t.uri, &res)
return t.GetJSON(uri, &res)
}, bo); err != nil {
once.Do(func() { done <- err })

Expand Down
2 changes: 1 addition & 1 deletion tariff/amber/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package amber

const URI = "https://api.amber.com.au/v1/sites/%s/prices?endDate=%s&resolution=30"
const URI = "https://api.amber.com.au/v1/sites/%s/prices?resolution=30"

type PriceInfo struct {
Type string `json:"type"`
Expand Down

0 comments on commit 671a580

Please sign in to comment.