Easee: prevent internal current updates on failed API calls (#7825)
* prevent internal current updates on failed API calls * incorporate review feedback on error handling * wip --------- Co-authored-by: andig <cpuidle@gmx.de>
This commit is contained in:
parent
c46c9372ac
commit
4e66c01803
1 changed files with 5 additions and 1 deletions
|
|
@ -415,8 +415,12 @@ func (c *Easee) MaxCurrent(current int64) error {
|
|||
uri := fmt.Sprintf("%s/chargers/%s/settings", easee.API, c.charger)
|
||||
resp, err := c.Post(uri, request.JSONContent, request.MarshalJSON(data))
|
||||
if err == nil {
|
||||
c.current = cur
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 202 && resp.ContentLength <= 2 {
|
||||
// no tick id, Easee effectively ignored this update
|
||||
return api.ErrMustRetry
|
||||
}
|
||||
c.current = cur
|
||||
}
|
||||
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue