Enyaq: add soc limit

This commit is contained in:
andig 2022-11-10 16:02:42 +01:00
parent 5f551b1399
commit b01b1830d2

View file

@ -9,9 +9,10 @@ import (
// Provider implements the evcc vehicle api
type Provider struct {
statusG func() (StatusResponse, error)
chargerG func() (ChargerResponse, error)
action func(action, value string) error
statusG func() (StatusResponse, error)
chargerG func() (ChargerResponse, error)
settingsG func() (SettingsResponse, error)
action func(action, value string) error
}
// NewProvider provides the evcc vehicle api provider
@ -26,6 +27,9 @@ func NewProvider(api *API, vin string, cache time.Duration) *Provider {
// climateG: provider.Cached(func() (interface{}, error) {
// return api.Climater(vin)
// }, cache),
settingsG: provider.Cached(func() (SettingsResponse, error) {
return api.Settings(vin)
}, cache),
action: func(action, value string) error {
return api.Action(vin, action, value)
},
@ -121,6 +125,18 @@ func (v *Provider) Odometer() (odo float64, err error) {
// return active, outsideTemp, targetTemp, err
// }
var _ api.SocLimiter = (*Provider)(nil)
// TargetSoC implements the api.SocLimiter interface
func (v *Provider) TargetSoC() (float64, error) {
res, err := v.settingsG()
if err == nil {
return float64(res.TargetStateOfChargeInPercent), nil
}
return 0, err
}
var _ api.VehicleChargeController = (*Provider)(nil)
// StartCharge implements the api.VehicleChargeController interface