From 5561192041b1d26ff6a1bf368658c83cc839f5aa Mon Sep 17 00:00:00 2001 From: fabianhu Date: Wed, 29 Nov 2023 23:46:35 +0100 Subject: [PATCH 1/2] add commands to schedule charging tesla-control charging-schedule [minutes after midnight]: activates daily scheduling at given time. tesla-control charging-schedule-cancel: cancels the schedule - side effect: charging starts right away, when connected. --- cmd/tesla-control/commands.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/tesla-control/commands.go b/cmd/tesla-control/commands.go index aa40972..2a446a9 100644 --- a/cmd/tesla-control/commands.go +++ b/cmd/tesla-control/commands.go @@ -453,6 +453,31 @@ var commands = map[string]*Command{ return car.ChargeStop(ctx) }, }, + "charging-schedule": &Command{ + help: "Schedule charging to xx minutes after midnight and enable daily scheduling", + requiresAuth: true, + requiresFleetAPI: false, + args: []Argument{ + Argument{name: "MINS", help: "Time after midnight in minutes"}, + }, + handler: func(ctx context.Context, acct *account.Account, car *vehicle.Vehicle, args map[string]string) error { + minutesAfterMidnight, err := strconv.Atoi(args["MINS"]) + if err != nil { + return fmt.Errorf("error parsing minutes") + } + // Convert minutes to a time.Duration + chargingTime := time.Duration(minutesAfterMidnight) * time.Minute + return car.ScheduleCharging(ctx, true, chargingTime) + }, + }, + "charging-schedule-cancel": &Command{ + help: "Cancel scheduled charge start", + requiresAuth: true, + requiresFleetAPI: false, + handler: func(ctx context.Context, acct *account.Account, car *vehicle.Vehicle, args map[string]string) error { + return car.ScheduleCharging(ctx, false, 0*time.Hour) + }, + }, "media-set-volume": &Command{ help: "Set volume", requiresAuth: true, From 594074fa88862ab050606ee3e89f65860c030460 Mon Sep 17 00:00:00 2001 From: fabianhu Date: Thu, 30 Nov 2023 00:59:01 +0100 Subject: [PATCH 2/2] fixed MINS text according convention --- cmd/tesla-control/commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/tesla-control/commands.go b/cmd/tesla-control/commands.go index 2a446a9..3c3536a 100644 --- a/cmd/tesla-control/commands.go +++ b/cmd/tesla-control/commands.go @@ -454,7 +454,7 @@ var commands = map[string]*Command{ }, }, "charging-schedule": &Command{ - help: "Schedule charging to xx minutes after midnight and enable daily scheduling", + help: "Schedule charging to MINS minutes after midnight and enable daily scheduling", requiresAuth: true, requiresFleetAPI: false, args: []Argument{