Skip to content

Commit

Permalink
Renault: fix odometer not available
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed May 4, 2024
1 parent 64e4548 commit 8327ddb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion vehicle/renault/kamereon/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion vehicle/renault/kamereon/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 6 additions & 3 deletions vehicle/renault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 0, err
}

if err == nil {
return res.Data.Attributes.TotalMileage, nil
if res.Data.Attributes.TotalMileage != nil {
return *res.Data.Attributes.TotalMileage, nil
}

return 0, err
return 0, api.ErrNotAvailable
}

var _ api.VehicleFinishTimer = (*Provider)(nil)
Expand Down

0 comments on commit 8327ddb

Please sign in to comment.