diff --git a/vehicle/psa/provider.go b/vehicle/psa/provider.go index 20b9b005d..978629c38 100644 --- a/vehicle/psa/provider.go +++ b/vehicle/psa/provider.go @@ -138,3 +138,18 @@ func (v *Provider) Climater() (active bool, outsideTemp float64, targetTemp floa return active, outsideTemp, targetTemp, 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.(Status); err == nil && ok { + if coord := res.LastPosition.Geometry.Coordinates; len(coord) == 2 { + return coord[0], coord[1], nil + } + return 0, 0, api.ErrNotAvailable + } + + return 0, 0, err +} diff --git a/vehicle/psa/types.go b/vehicle/psa/types.go index 202e8652d..0e3183a8e 100644 --- a/vehicle/psa/types.go +++ b/vehicle/psa/types.go @@ -37,6 +37,18 @@ type Status struct { Odometer struct { Mileage float64 } `json:"timed.odometer"` + LastPosition struct { + Type string + Geometry struct { + Type string + Coordinates []float64 + } + Properties struct { + UpdatedAt time.Time + Type string + Heading int + } + } } // Energy is the /status partial energy response