Niu: add odometer (#20763)
This commit is contained in:
parent
20f6d3403d
commit
049075043b
2 changed files with 17 additions and 0 deletions
|
|
@ -154,3 +154,17 @@ func (v *Niu) Range() (int64, error) {
|
||||||
res, err := v.apiG()
|
res, err := v.apiG()
|
||||||
return res.Data.EstimatedMileage, err
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,5 +63,8 @@ type Response struct {
|
||||||
}
|
}
|
||||||
// LeftTime float32 `json:"leftTime,omitempty"`
|
// LeftTime float32 `json:"leftTime,omitempty"`
|
||||||
EstimatedMileage int64 `json:"estimatedMileage,omitempty"`
|
EstimatedMileage int64 `json:"estimatedMileage,omitempty"`
|
||||||
|
|
||||||
|
// overallTally
|
||||||
|
TotalMileage float64 `json:"totalMileage,omitempty"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue