From f24b670312ec7149b0fabe6da3397e2b8279f80f Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 2 Apr 2026 18:10:00 +0200 Subject: [PATCH] chore: minor --- vehicle/homeassistant.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vehicle/homeassistant.go b/vehicle/homeassistant.go index af16614bd..23d0be438 100644 --- a/vehicle/homeassistant.go +++ b/vehicle/homeassistant.go @@ -103,11 +103,18 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error if cc.Sensors.FinishTime != "" { finish = func() (time.Time, error) { return conn.GetTimeState(cc.Sensors.FinishTime) } } + if cc.Services.Start != "" && cc.Services.Stop != "" { - enable = func(enable bool) error { return res.enable(cc.Services.Start, cc.Services.Stop, enable) } + enable = func(enable bool) error { + if enable { + return conn.CallSwitchService(cc.Services.Start, true) + } + return conn.CallSwitchService(cc.Services.Stop, true) + } } else if strings.HasPrefix(cc.Services.Start, "switch") { enable = func(enable bool) error { return conn.CallSwitchService(cc.Services.Start, enable) } } + if cc.Services.Wakeup != "" { wakeup = func() error { return conn.CallSwitchService(cc.Services.Wakeup, true) } } @@ -136,11 +143,3 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error func (v *HomeAssistant) Soc() (float64, error) { return v.conn.GetFloatState(v.soc) } - -func (v *HomeAssistant) enable(on, off string, enable bool) error { - if enable { - return v.conn.CallSwitchService(on, true) - } - - return v.conn.CallSwitchService(off, true) -}