mercedes-byocar-exporter/internal/mercedes/fuel_status.go

28 lines
582 B
Go
Raw Normal View History

2022-11-19 23:47:19 +00:00
package mercedes
import (
"fmt"
"github.com/pkg/errors"
)
type (
FuelStatus struct {
RangeLiquid TimedInt `apiField:"rangeliquid"` // Liquid fuel tank range 0..2046 km
TanklevelPercent TimedInt `apiField:"tanklevelpercent"` // Liquid fuel tank level 0…100 %
}
)
func (a APIClient) GetFuelStatus(vehicleID string) (FuelStatus, error) {
var (
path = fmt.Sprintf("/vehicles/%s/containers/fuelstatus", vehicleID)
out FuelStatus
)
if err := a.request(path, &out); err != nil {
return out, errors.Wrap(err, "getting fuel status")
}
return out, nil
}