Fiat: ignore HTTP 403 during deep refresh (#13428)

This commit is contained in:
andig 2024-04-14 15:52:49 +02:00 • committed by GitHub
parent 3740a31990
commit ab412b41b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,11 +1,14 @@
package fiat
import (
"errors"
"fmt"
"net/http"
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/provider"
"github.com/evcc-io/evcc/util/request"
)
const refreshTimeout = 2 * time.Minute
@ -48,6 +51,11 @@ func (v *Provider) deepRefresh() error {
res, err := v.action("ev", "DEEPREFRESH")
if err == nil && res.ResponseStatus != "pending" {
err = fmt.Errorf("invalid response status: %s", res.ResponseStatus)
} else {
var se request.StatusError
if errors.As(err, &se) && se.StatusCode() == http.StatusForbidden {
err = nil
}
}
return err
}