Renault: fix odometer not available
This commit is contained in:
parent
64e45488e8
commit
8327ddbb21
3 changed files with 9 additions and 6 deletions
|
|
@ -118,7 +118,7 @@ func (v *API) Hvac(accountID string, vin string) (Response, error) {
|
|||
|
||||
// Cockpit provides cockpit api response
|
||||
func (v *API) Cockpit(accountID string, vin string) (Response, error) {
|
||||
uri := fmt.Sprintf("%s/commerce/v1/accounts/%s/kamereon/kca/car-adapter/v2/cars/%s/cockpit", v.keys.Target, accountID, vin)
|
||||
uri := fmt.Sprintf("%s/commerce/v1/accounts/%s/kamereon/kca/car-adapter/v1/cars/%s/cockpit", v.keys.Target, accountID, vin)
|
||||
return v.request(uri, nil)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ type attributes struct {
|
|||
ExternalTemperature float64 `json:"externalTemperature"`
|
||||
HvacStatus string `json:"hvacStatus"`
|
||||
// cockpit
|
||||
TotalMileage float64 `json:"totalMileage"`
|
||||
TotalMileage *float64 `json:"totalMileage"`
|
||||
// position
|
||||
Latitude float64 `json:"gpsLatitude"`
|
||||
Longitude float64 `json:"gpsLongitude"`
|
||||
|
|
|
|||
|
|
@ -103,12 +103,15 @@ var _ api.VehicleOdometer = (*Provider)(nil)
|
|||
// Odometer implements the api.VehicleOdometer interface
|
||||
func (v *Provider) Odometer() (float64, error) {
|
||||
res, err := v.cockpitG()
|
||||
|
||||
if err == nil {
|
||||
return res.Data.Attributes.TotalMileage, nil
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, err
|
||||
if res.Data.Attributes.TotalMileage != nil {
|
||||
return *res.Data.Attributes.TotalMileage, nil
|
||||
}
|
||||
|
||||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
var _ api.VehicleFinishTimer = (*Provider)(nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue