Skip to content

Add support for navigation_waypoints_request command - #443

Open
matthieu6010 wants to merge 3 commits into
teslamotors:mainfrom
matthieu6010:add-navigation-waypoints-request
Open

Add support for navigation_waypoints_request command#443
matthieu6010 wants to merge 3 commits into
teslamotors:mainfrom
matthieu6010:add-navigation-waypoints-request

Conversation

@matthieu6010

Copy link
Copy Markdown

Summary

Implements the signed navigation_waypoints_request command so that Tesla vehicles with vehicle_command_protocol_required: true can receive a full multi-stop route via the Fleet API.

The endpoint is documented in the Fleet API reference but was not implemented here — raw REST calls return "Tesla Vehicle Command Protocol required", and before this change the proxy returned invalid_command. Part of #188 and the sub-request in #334.

Changes

  • pkg/protocol/protobuf/car_server.proto — add NavigationWaypointsRequest message (with nested TripPlanOptions) and wire it into the VehicleAction oneof at tag 90, matching the schema used by the Tesla mobile app:

    NavigationWaypointsRequest navigationWaypointsRequest = 90;
    
    message NavigationWaypointsRequest {
        string waypoints = 1;
        TripPlanOptions trip_plan_options = 2;
    
        message TripPlanOptions {
            int32 destination_start_soe = 1;
            int32 destination_arrival_soe = 2;
        }
    }
  • pkg/protocol/protobuf/carserver/car_server.pb.go — regenerated via make proto-gen (protoc 3.21.9, protoc-gen-go v1.28.1, same versions as the existing file header). The large diff is essentially protoc output noise; the substantive additions are the VehicleAction_NavigationWaypointsRequest oneof case, the two new structs, and their wire-method scaffolding.

  • pkg/vehicle/navigation.go (new) — adds (v *Vehicle) NavigateToWaypoints(ctx, waypoints), which follows the same executeCarServerAction pattern as other command helpers.

  • pkg/proxy/command.go — adds the "navigation_waypoints_request" case that parses the required waypoints body field and dispatches the signed command.

Usage

POST https://<proxy>/api/1/vehicles/<vin>/command/navigation_waypoints_request
Content-Type: application/json

{"waypoints": "refId:ChIJ...,refId:ChIJ...,refId:ChIJ..."}

The last entry is the final destination; preceding entries are intermediate stops. refId: values are Google Maps place IDs.

Test plan

  • go build ./... clean
  • go vet ./... clean
  • End-to-end test against a real Model 3 (firmware 2026.14.1), with three waypoints:
    • API returns {"result":true,"reason":""}
    • In-dash nav correctly shows the full multi-leg route in order
    • Trip planner automatically inserts a Supercharger stop when range is insufficient (as expected from the in-app behaviour)

Notes for reviewers

  • I derived the protobuf schema by inspecting the Tesla Android app; happy to share more details if the maintainers want to confirm tag numbers against their internal definitions.
  • navigation_gps_request, navigation_sc_request, navigation_route_action, and navigation_gps_destination_request are also currently missing from the proxy switch but are out of scope for this PR. Can follow up in a separate change if there's interest.

The `navigation_waypoints_request` endpoint is documented in the Fleet API
reference[1] but was not implemented in this library. Vehicles with
`vehicle_command_protocol_required: true` reject the raw REST call with
"Tesla Vehicle Command Protocol required", and the proxy previously
returned `invalid_command` for this endpoint.

This change:

- Adds the `NavigationWaypointsRequest` protobuf message definition in
  `car_server.proto`, matching the schema used by the Tesla mobile app:
    * `string waypoints = 1`       — comma-separated `refId:<placeId>` list
    * `TripPlanOptions trip_plan_options = 2`
         * `int32 destination_start_soe = 1`
         * `int32 destination_arrival_soe = 2`
  Wired into the `VehicleAction` oneof at tag 90.
- Regenerates `car_server.pb.go` via `make proto-gen` (the large diff is
  due to protoc version drift; the actual logical change is limited to the
  new `VehicleAction_NavigationWaypointsRequest` case, the new
  `NavigationWaypointsRequest` / `NavigationWaypointsRequest_TripPlanOptions`
  structs, and their wire-method scaffolding).
- Adds `(v *Vehicle) NavigateToWaypoints(ctx, waypoints)` in a new file
  `pkg/vehicle/navigation.go`, following the same `executeCarServerAction`
  pattern as other command helpers.
- Adds the `"navigation_waypoints_request"` case to the proxy command
  switch, parsing the required `waypoints` string body and dispatching the
  signed command.

Usage (via the proxy):

    POST https://<proxy>/api/1/vehicles/<vin>/command/navigation_waypoints_request
    {"waypoints": "refId:ChIJ...,refId:ChIJ...,refId:ChIJ..."}

The last entry is the final destination; preceding entries are intermediate
stops. The car navigates through all of them in order, and the built-in
trip planner automatically inserts Supercharger stops when the battery
range is insufficient.

Tested end-to-end against a Model 3 (firmware 2026.14.1) with three stops:
the API returns `{"result":true,"reason":""}` and the on-dash navigation
displays the full multi-leg route.

Addresses part of teslamotors#188 and the sub-request in teslamotors#334 for
`navigation_waypoints_request`.

[1] https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-commands
Lets callers specify the trip planner's starting/arrival target SoC (in
integer percent). Leaving both at 0 preserves the previous behaviour
(Tesla applies its conservative defaults, which can insert Supercharger
stops aggressively).

- Adds `NavigateToWaypointsWithOptions` in pkg/vehicle/navigation.go.
  `NavigateToWaypoints` is kept as a thin wrapper for backward compat.
- The proxy parses the optional `destination_start_soe` and
  `destination_arrival_soe` numeric body fields and forwards them.
Comment thread pkg/vehicle/navigation.go Outdated
// The last place in the list is the final destination; preceding entries are
// intermediate stops. The car will route through all of them in order.
//
// See https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-commands

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pkg/vehicle/navigation.go Outdated
// "refId:ChIJxxx,refId:ChIJyyy,refId:ChIJzzz"
//
// The last place in the list is the final destination; preceding entries are
// intermediate stops. The car will route through all of them in order.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to "vehicle" rather than "car" in documentation strings. Also in first paragraph.

Comment thread pkg/protocol/protobuf/car_server.proto Outdated
BatchRemoveChargeSchedulesAction batchRemoveChargeSchedulesAction = 108;
SetLowPowerModeAction setLowPowerModeAction = 130;
SetKeepAccessoryPowerModeAction setKeepAccessoryPowerModeAction = 138;
NavigationWaypointsRequest navigationWaypointsRequest = 90;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put in field order

Comment thread pkg/protocol/protobuf/car_server.proto Outdated
message NavigationWaypointsRequest {
string waypoints = 1;
TripPlanOptions trip_plan_options = 2;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rearrange to match internal order:

message NavigationWaypointsRequest {
    message TripPlanOptions {
        int32 destination_start_soe = 1;
        int32 destination_arrival_soe = 2;
    }
    string waypoints = 1;
    TripPlanOptions trip_plan_options = 2;
}

@sethterashima

Copy link
Copy Markdown
Collaborator

Appreciate the PR. I left a few nits and will try to validate this week or next.

- Replace 'car' with 'vehicle' in NavigateToWaypoints docstrings
- Add full Tesla Fleet API doc link with anchor (#navigation-waypoints-request)
- Move navigationWaypointsRequest = 90 into numeric field order in VehicleAction oneof
- Hoist TripPlanOptions nested message definition before field declarations in NavigationWaypointsRequest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants