Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add commands to schedule charging #68

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cmd/tesla-control/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,31 @@ var commands = map[string]*Command{
return car.ChargeStop(ctx)
},
},
"charging-schedule": &Command{
help: "Schedule charging to MINS 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,
Expand Down