teslamotors / vehicle-command

Apache License 2.0
388 stars 87 forks source link

Command SDK doesn't recognize window_control #43

Open stx opened 8 months ago

stx commented 8 months ago

window_control is missing from this switch statement, which causes window controls to work through Fleet API but not the SDK:

https://github.com/teslamotors/vehicle-command/blob/main/pkg/proxy/execute.go#L110


Fleet API:

curl -H "Authorization: Bearer <token>" -H "Content-Type: application/json" --data '{"command":"vent"}' https://fleet-api.prd.na.vn.cloud.tesla.com/api/1/vehicles/<vehicle_id>/command/window_control

-> {"response":{"result":true,"reason":""}}

Command SDK:

curl -H "Authorization: Bearer <token>" -H "Content-Type: application/json" --data '{"command":"vent"}' https://localhost:4443/api/1/vehicles/<vin>/command/window_control

-> {"response":null,"error":"invalid_command","error_description":""}
rawmean commented 8 months ago

Add this to pkg/proxy/execute.go after line 419

    case "window_control":
        cmd, err := params.getString("command", true)
        if err != nil {
            return err
        }
        if cmd == "vent" {
            return car.VentWindows(ctx)
        } else {
            return car.CloseWindows(ctx)
        }
ststolz commented 4 months ago

Fix for current main:

https://github.com/teslamotors/vehicle-command/compare/main...ststolz:ststolz-tesla-vehicle-command:main