From 005c0f8f1411b4e0e003c1a88547f46cf5e85302 Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 11 May 2021 10:53:25 +0200 Subject: [PATCH] ID: add charge stop api --- internal/vehicle/id/provider.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/vehicle/id/provider.go b/internal/vehicle/id/provider.go index 5473a0a3d..fe4eff729 100644 --- a/internal/vehicle/id/provider.go +++ b/internal/vehicle/id/provider.go @@ -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) }