Porsche: simplify login (#2960)
This commit is contained in:
parent
7aa179419b
commit
af46b731fa
1 changed files with 4 additions and 25 deletions
|
|
@ -73,32 +73,11 @@ func NewPorscheFromConfig(other map[string]interface{}) (api.Vehicle, error) {
|
|||
return nil, errors.New("vehicle is not paired with the My Porsche account")
|
||||
}
|
||||
|
||||
// check if vehicle provides status:
|
||||
// some PHEVs do not provide any data
|
||||
statusAvailable := false
|
||||
if _, err := mobile.Status(cc.VIN); err == nil {
|
||||
statusAvailable = true
|
||||
}
|
||||
|
||||
if _, err := api.Status(cc.VIN); err == nil {
|
||||
statusAvailable = true
|
||||
}
|
||||
|
||||
if !statusAvailable {
|
||||
return nil, errors.New("vehicle is not capable of providing data")
|
||||
}
|
||||
|
||||
// get eMobility capabilities
|
||||
|
||||
// Note: As of 27.10.21 the capabilities API needs to be called AFTER a
|
||||
// call to status() as it otherwise returns an HTTP 502 error.
|
||||
// The reason is unknown, even when tested with 100% identical Headers.
|
||||
// It seems to be a new backend related issue.
|
||||
var emobility *porsche.EmobilityAPI
|
||||
var capabilities porsche.CapabilitiesResponse
|
||||
if _, err := api.Status(cc.VIN); err == nil {
|
||||
emobility = porsche.NewEmobilityAPI(log, identity.EmobilitySource)
|
||||
capabilities, _ = emobility.Capabilities(cc.VIN)
|
||||
emobility := porsche.NewEmobilityAPI(log, identity.EmobilitySource)
|
||||
capabilities, err := emobility.Capabilities(cc.VIN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
provider := porsche.NewProvider(log, api, emobility, mobile, cc.VIN, capabilities.CarModel, cc.Cache)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue