diff --git a/vehicle/niu.go b/vehicle/niu.go index 114a8f3c5..664c8e28e 100644 --- a/vehicle/niu.go +++ b/vehicle/niu.go @@ -154,3 +154,17 @@ func (v *Niu) Range() (int64, error) { res, err := v.apiG() return res.Data.EstimatedMileage, err } + +var _ api.VehicleOdometer = (*Niu)(nil) + +// Odometer implements the api.VehicleOdometer interface +func (v *Niu) Odometer() (float64, error) { + var res niu.Response + + req, err := v.request(niu.ApiURI + "/overallTally?sn=" + v.serial) + if err == nil { + err = v.DoJSON(req, &res) + } + + return res.Data.TotalMileage, err +} diff --git a/vehicle/niu/types.go b/vehicle/niu/types.go index e4729d4c7..5944f6279 100644 --- a/vehicle/niu/types.go +++ b/vehicle/niu/types.go @@ -63,5 +63,8 @@ type Response struct { } // LeftTime float32 `json:"leftTime,omitempty"` EstimatedMileage int64 `json:"estimatedMileage,omitempty"` + + // overallTally + TotalMileage float64 `json:"totalMileage,omitempty"` } }