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 Tesla using official vehicle command library #10802

Merged
merged 22 commits into from
Jan 24, 2024
Prev Previous commit
Next Next commit
wip
  • Loading branch information
andig committed Dec 22, 2023
commit 5bcfb6b5c9d8fc8d7defd59866a80ee167fa3d21
4 changes: 2 additions & 2 deletions vehicle/tesla-vehicle-command.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ func NewTeslaVCFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}

res := &struct {
api.Vehicle
*TeslaVC
*vc.CommandSession
}{
Vehicle: v,
TeslaVC: v,
CommandSession: cs,
}

Expand Down
5 changes: 4 additions & 1 deletion vehicle/tesla-vehicle-command/helper.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package vc

import (
"errors"
"strings"

"github.com/evcc-io/evcc/api"
"github.com/teslamotors/vehicle-command/pkg/connector/inet"
)

// ApiError converts HTTP 408 error to ErrTimeout
func ApiError(err error) error {
if err != nil && (strings.HasSuffix(err.Error(), "408 Request Timeout") || strings.HasSuffix(err.Error(), "408 (Request Timeout)")) {
if err != nil && (errors.Is(err, inet.ErrVehicleNotAwake) ||
strings.HasSuffix(err.Error(), "408 Request Timeout") || strings.HasSuffix(err.Error(), "408 (Request Timeout)")) {
err = api.ErrAsleep
}
return err
Expand Down