Add vehicle position api (#2021)

This commit is contained in:
andig 2021-12-11 12:47:08 +01:00 • committed by GitHub
parent a0e07e83a9
commit 981b23dd56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -164,6 +164,11 @@ type VehicleOdometer interface {
Odometer() (float64, error)
}
// VehiclePosition returns the vehicles position in latitude and longitude
type VehiclePosition interface {
Position() (float64, float64, error)
}
// VehicleStartCharge starts the charging session on the vehicle side
type VehicleStartCharge interface {
StartCharge() error

View file

@ -162,6 +162,14 @@ func (d *dumper) Dump(name string, v interface{}) {
}
}
if v, ok := v.(api.VehiclePosition); ok {
if lat, lon, err := v.Position(); err != nil {
fmt.Fprintf(w, "Position:\t%v\n", err)
} else {
fmt.Fprintf(w, "Position:\t%v,%v\n", lat, lon)
}
}
if v, ok := v.(api.Vehicle); ok {
fmt.Fprintf(w, "Capacity:\t%dkWh\n", v.Capacity())
if len(v.Identifiers()) > 0 {