Skip to content

Commit

Permalink
Ford: add position and odometer (#2202)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris591 committed Jan 5, 2022
1 parent ae2c1bd commit 138722c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions vehicle/ford/provider.go
Expand Up @@ -112,3 +112,27 @@ func (v *Provider) Status() (api.ChargeStatus, error) {

return status, err
}

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

// Odometer implements the api.VehicleOdometer interface
func (v *Provider) Odometer() (float64, error) {
res, err := v.statusG()
if res, ok := res.(StatusResponse); err == nil && ok {
return res.VehicleStatus.Odometer.Value, nil
}

return 0, err
}

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

// Position implements the api.VehiclePosition interface
func (v *Provider) Position() (float64, float64, error) {
res, err := v.statusG()
if res, ok := res.(StatusResponse); err == nil && ok {
return res.VehicleStatus.Gps.Latitude, res.VehicleStatus.Gps.Longitude, nil
}

return 0, 0, err
}
10 changes: 10 additions & 0 deletions vehicle/ford/types.go
Expand Up @@ -32,6 +32,16 @@ type StatusResponse struct {
Value int
Timestamp Timestamp
}
Odometer struct {
Value float64
Timestamp Timestamp
}
Gps struct {
Latitude float64 `json:",string"`
Longitude float64 `json:",string"`
GpsState string
Timestamp Timestamp
}
LastRefresh Timestamp
}
Status int
Expand Down

0 comments on commit 138722c

Please sign in to comment.