ID: add charge stop api
This commit is contained in:
parent
cb93b9b2f1
commit
005c0f8f14
1 changed files with 12 additions and 5 deletions
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
// Provider is an api.Vehicle implementation for VW ID cars
|
||||
type Provider struct {
|
||||
statusG func() (interface{}, error)
|
||||
startChargeAction func() error
|
||||
statusG func() (interface{}, error)
|
||||
action func(action, value string) error
|
||||
}
|
||||
|
||||
// NewProvider creates a new vehicle
|
||||
|
|
@ -20,8 +20,8 @@ func NewProvider(api *API, vin string, cache time.Duration) *Provider {
|
|||
statusG: provider.NewCached(func() (interface{}, error) {
|
||||
return api.Status(vin)
|
||||
}, cache).InterfaceGetter(),
|
||||
startChargeAction: func() error {
|
||||
return api.Action(vin, ActionCharge, ActionChargeStart)
|
||||
action: func(action, value string) error {
|
||||
return api.Action(vin, action, value)
|
||||
},
|
||||
}
|
||||
return impl
|
||||
|
|
@ -113,5 +113,12 @@ var _ api.VehicleStartCharge = (*Provider)(nil)
|
|||
|
||||
// StartCharge implements the api.VehicleStartCharge interface
|
||||
func (v *Provider) StartCharge() error {
|
||||
return v.startChargeAction()
|
||||
return v.action(ActionCharge, ActionChargeStart)
|
||||
}
|
||||
|
||||
var _ api.VehicleStopCharge = (*Provider)(nil)
|
||||
|
||||
// StopCharge implements the api.VehicleStopCharge interface
|
||||
func (v *Provider) StopCharge() error {
|
||||
return v.action(ActionCharge, ActionChargeStop)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue