Enyaq: add soc limit
This commit is contained in:
parent
5f551b1399
commit
b01b1830d2
1 changed files with 19 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue