Porsche: add wakeup (#10928)

This commit is contained in:
MarkusGH 2023-12-07 07:58:26 +01:00 • committed by GitHub
parent 3c78c6ac38
commit dca99c30bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View file

@ -2,6 +2,7 @@ package porsche
import (
"fmt"
"net/http"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
@ -67,3 +68,17 @@ func (v *API) Status(vin string) (StatusResponse, error) {
err := v.GetJSON(uri, &res)
return res, err
}
// WakeUp tries to wakeup the vehicle by requesting the current vehicle overview
func (v *API) WakeUp(vin string) error {
uri := fmt.Sprintf("%s/service-vehicle/de/de_DE/vehicle-data/%s/current/request", ApiURI, vin)
req, err := request.New(http.MethodPost, uri, nil, request.AcceptJSON)
if err != nil {
return err
}
resp, err := v.Do(req)
if err == nil {
resp.Body.Close()
}
return err
}

View file

@ -31,11 +31,7 @@ func NewProvider(log *util.Logger, connect *API, emobility *EmobilityAPI, vin, c
}, cache),
wakeup: func() error {
_, err := connect.Status(vin)
if err != nil && carModel != "" {
_, _ = emobility.Status(vin, carModel)
}
return nil
return connect.WakeUp(vin)
},
}