mercedes-byocar-exporter/internal/mercedes/electric.go
Knut Ahlers b51d41f15e
Add support for electric vehicles
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-12-04 00:27:08 +01:00

29 lines
602 B
Go

package mercedes
import (
"fmt"
"github.com/pkg/errors"
)
type (
ElectricStatus struct {
// Displayed state of charge for the HV battery 0..100 %
StateOfCharge TimedInt `apiField:"soc"`
// Electric range 0..2046 km
ElectricRange TimedInt `apiField:"rangeelectric"`
}
)
func (a APIClient) GetElectricStatus(vehicleID string) (ElectricStatus, error) {
var (
path = fmt.Sprintf("/vehicles/%s/containers/electricvehicle", vehicleID)
out ElectricStatus
)
if err := a.request(path, &out); err != nil {
return out, errors.Wrap(err, "getting electric status")
}
return out, nil
}