Skip to content

Commit

Permalink
Enyaq: add soc limit
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Nov 10, 2022
1 parent 5f551b1 commit b01b183
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions vehicle/skoda/provider.go
Expand Up @@ -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
Expand All @@ -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)
},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b01b183

Please sign in to comment.