Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Odometer interface for Cupra Born #8340

Merged
merged 5 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions vehicle/seat/cupra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ func (v *Provider) Range() (int64, error) {
return int64(res.Engines.Primary.Range.Value), err
}

var _ api.VehicleOdometer = (*Provider)(nil)

// Odometer implements the api.VehicleOdometer interface
func (v *Provider) Odometer() (float64, error) {
res, err := v.statusG()
return float64(res.Measurements.MileageKm), err
}

var _ api.VehicleClimater = (*Provider)(nil)

// Climater implements the api.VehicleClimater interface
Expand All @@ -97,11 +105,7 @@ var _ api.SocLimiter = (*Provider)(nil)
// TargetSoc implements the api.SocLimiter interface
func (v *Provider) TargetSoc() (float64, error) {
res, err := v.statusG()
if err == nil {
return float64(res.Services.Charging.TargetPct), nil
}

return 0, err
return float64(res.Services.Charging.TargetPct), err
}

var _ api.VehicleChargeController = (*Provider)(nil)
Expand Down
3 changes: 3 additions & 0 deletions vehicle/seat/cupra/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ type Status struct {
ProgressBarPct float64
}
}
Measurements struct {
MileageKm float64
}
}