Amber: fix api query (#13196)
This commit is contained in:
parent
92884c27b3
commit
671a580d51
2 changed files with 5 additions and 4 deletions
|
|
@ -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),
|
||||
}
|
||||
|
|
@ -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 })
|
||||
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue