Repository navigation
Add Parallax equivalents of vehicle commands - #245
Conversation
|
#252, #246 and #248 have been merged, so this now conflicts with They will land in this order, so rebasing in the same order keeps the later ones from conflicting again:
I've moved this to draft for now; please mark it ready for review once it's rebased. |
The server ends a subscription with an `error` message when it fails, for example when the vehicle refuses a command the subscription waits on. The web socket only logged those at debug, so a caller waiting on the subscription could only time out. Subscriptions can now take an `on_error` callback that gets the error message; existing callers are unchanged.
An `on_error` that raised escaped the receive loop and ended the receiver task. Both callbacks now run through `_run_callback`, which logs a failure instead of raising and awaits coroutine callbacks.
`start_gear_guard_live_stream` starts a live camera stream the way the Rivian app does and returns its Kinesis Video WebRTC config (signaling endpoint, ICE servers and role), for a viewer to join: - It subscribes to `gearGuardLiveConfig` with a fresh command id, then sends the signed `security.video_monitoring.start_live_streaming` command with that same id; the cloud routes the config by it. - `parallax.encode_live_streaming` builds the command's payload from a new `LiveStreamingRequest` schema; `GEAR_GUARD_CAMERAS` names the cameras. - A refused start (e.g. a camera the vehicle doesn't have) raises RivianApiException straight away, through the subscription's `on_error`. It needs Gear Guard video monitoring on and a paired phone. The vehicle serves one session at a time, about 3 minutes each and an hour a day. Builds on bretterer#249. Verified against a 2026 R1S (Gen 2) running 2026.36.01: the config arrived within seconds of the start when the vehicle was awake, and the front and right cameras streamed in a WebRTC viewer. A sleeping vehicle can take longer to wake than the default 40 second timeout. Not tested: the rear, left and bed cameras, the R2's cabin camera.
A refusal that reached the future before the start command was rejected was never read, so asyncio logged "Future exception was never retrieved"; it is now read before returning. The error handler also takes a `payload` sent as an object, not only as a list, so it still fails the start instead of raising in the callback.
- `search_places` searches like the Rivian app's map search (its `places` query): results with a Google place id, name, address, coordinates and the driving distance and time from where you search. - `suggest_places` returns the app's suggested search texts for partial text (the same query with autocomplete), such as "restaurants" and "Red Lobster" for "RE", for type-ahead in front of `search_places`. - `utils.place_url` builds the Rivian app's link for a result, which `send_location_to_vehicle` sends so the vehicle shows the place's name. None of them needs a paired phone key. Tested against the API: a search returned Google's results in under a second, in their own order rather than nearest first, and suggestions came back in about a tenth of a second. `maxResults` was ignored, so it is left out.
Encoders for the payloads of the signed `comfort.cabin.set_climate_hold` and
`comfort.cabin.set_pet_mode` commands, both a single on/off action as in the
Rivian app:
await rivian.send_parallax_command(
vehicle_id, SET_PET_MODE_RVM, encode_pet_mode(True), ...
)
Verified against a 2026 R1S (Gen 2) running 2026.36.01: pet mode on/off and
climate hold on/off each reported the new state within seconds. The pet mode
payloads match the app's (captured with mitmproxy); the app's climate hold
control only sets the duration (`set_climate_hold_duration`), so that
payload comes from the app's code. Not tested: Gen 1 vehicles, the R1T and
R2.
New R1s and the R2 refuse `sendVehicleCommand` for commands they take over Parallax. Like the Rivian app, a command goes over Parallax when the vehicle reports its category's supported feature (`PVS_BD_CMD`, `PVS_SEC_CMD`, `PVS_COMF_CMD` or `PVS_ENRG_CMD`) as AVAILABLE. The liftgate needs `LIFTGATE_CMD`, so vehicles without it, such as an R1T with a tailgate, keep the old command. - `parallax.vehicle_command_feature` returns that feature for a command, or None for commands without an equivalent (wake, honk, flash, side bins). - `parallax.encode_vehicle_command` returns the RVM and payload to send with `send_parallax_command`, from the same `params` as `send_vehicle_command`. Locking uses the existing `encode_lock`/`encode_unlock`. Verified against a 2026 R1S (Gen 2) running 2026.36.01, which reports all four features and `LIFTGATE_CMD`: locks, windows, frunk, liftgate, front seat heat and vent, rear and third row seat heat, steering wheel heat, preconditioning and its temperature (including HI and LO), defrost, charge limit, start and stop charging, charge port, panic and Gear Guard video. The payloads match the Rivian app's. Not tested: the R1T and R2.
672c3c8 to
5fc9110
Compare
|
Rebased onto #247 in your merge order (so the diff shows the ones ahead until they land), and regenerated |
There was a problem hiding this comment.
Thanks for this. I checked the payloads against the Rivian app: every RVM name, field number and enum value matches, and so do the seat, steering wheel and defrost level conversions. Two things need changing before it can merge, plus a few smaller ones.
Needs changing
-
The liftgate is gated only on
LIFTGATE_CMD.vehicle_command_featurereturns"LIFTGATE_CMD"forOPEN_LIFTGATE_UNLATCH_TAILGATEandCLOSE_LIFTGATE, so a caller (like home-assistant-rivian#342) sends them over Parallax whenever that one feature is available. In the app,LIFTGATE_CMDonly decides whether the liftgate buttons are shown (VehicleComponentKt.isLiftgateSupported); whether a body command goes over Parallax depends only onPVS_BD_CMD, as for the other closures. So a vehicle withLIFTGATE_CMDbut withoutPVS_BD_CMD, likely a Gen 1 R1S, would have its liftgate moved to Parallax and stop working. The description says the liftgate "also needsLIFTGATE_CMD", so I think requiring both was the intent; gating it onPVS_BD_CMDlike the app would be simplest. -
Please follow the package's layout. The parallax package is organized by domain: each module (
body.py,comfort.py,charging.py,security.py) holds itsX_RVM: Finalconstants andencode_*functions, the way #247 and #250 just added theirs, and input validation lives inrivian.py(_validate_vehicle_command,set_climate_hold_duration).vehicle_command.pydiffers from that in a few ways:- About 15 RVM names are inline strings instead of constants in their domain modules.
- The closure, cabin surface, defrost, temperature and charge limit payloads are built here instead of as
encode_*functions inbody.py,comfort.pyandcharging.py. - It raises
RivianBadRequestErrorand re-implements the temperature, charge limit and level checks from_validate_vehicle_command; no other parallax module validates input, and two copies can drift apart. - Its constants aren't
Final, and the_Level = …and_OFF, _LOW, _MEDIUM, _HIGH = (…)aliases are unlike the rest of the package.
Moving the constants and encoders into their domain modules would leave
vehicle_command.pyas just the table from each command to its feature, RVM and encoder. For validation, sharing one set of checks withrivian.pyinstead of a second copy would keep them in step.
Smaller
- R1T tailgate. For
OPEN_LIFTGATE_UNLATCH_TAILGATEthe app sendsTAILGATEover Parallax on an R1T (andLIFTGATEon other models). This always sendsLIFTGATE, so a Gen 2 R1T falls back tosendVehicleCommand, which it refuses. It would need the vehicle model; fine as a follow-up since you haven't been able to test an R1T. - Side bins. The app opens them over Parallax too:
body.closures.openwithSIDE_BIN_LEFT/SIDE_BIN_RIGHT, forRELEASE_LEFT_SIDE_BIN/RELEASE_RIGHT_SIDE_BIN. Also fine as a follow-up. - LO comment.
PreconditioningTemperatureRequest.temperatureisoptional float, while the app's field is a plain float, so for LO (0 °C) the app sends an empty payload and this sends an explicit 0.0. The vehicle reads both as 0.0, so it's harmless, but the comment "sent even for 0 (LO)" reads as if that's what the app does.
- The liftgate goes over Parallax with `PVS_BD_CMD`, like the other closures, as in the app; `LIFTGATE_CMD` only decides whether its controls are shown. Gating on `LIFTGATE_CMD` alone could move a Gen 1 R1S liftgate to Parallax. - The RVM names are `Final` constants and the payloads are `encode_*` functions in `body.py`, `comfort.py` and `charging.py` (`security.py` for panic and Gear Guard video), exported from `rivian.parallax`. `vehicle_command.py` is now just the table from each command to its feature, RVM and encoder. - Validation lives in `rivian.py` only: `_validate_vehicle_command` is now the public `Rivian.validate_vehicle_command`, for callers sending the Parallax equivalent. It no longer turns the temperature into a string; `send_vehicle_command` does that itself. - The LO comment says what the app sends: an empty payload, which the vehicle reads as 0 like an explicit 0. Every command encodes exactly as before.
|
Thanks for going through it against the app. Follow-up pushed with 1, 2 and 5:
|
natekspencer
left a comment
There was a problem hiding this comment.
Thanks, the routing fix and the validation split look good. Encodings match the Rivian app and all tests pass. I'll follow up separately so encode_vehicle_command checks its own params.
|
Follow-up on 3 and 4: #255 sends the R1T tailgate and the side bins over Parallax, and both are tested on an R1T. One correction to my review: I said an R1T refuses the legacy |
Gen 2 R1s and the R2 refuse
sendVehicleCommandfor anything they take over Parallax. This maps vehicle commands to their Parallax equivalents, gated on the same supported features the Rivian app checks.parallax.vehicle_command_feature: the feature that gates a command (PVS_BD_CMD,PVS_SEC_CMD,PVS_COMF_CMD,PVS_ENRG_CMD), orNoneif there's no equivalent (wake, honk, flash, side bins)parallax.encode_vehicle_command: the RVM and payload forsend_parallax_command, from the sameparamsassend_vehicle_command, checked first withRivian.validate_vehicle_commandencode_*functions withFinalRVM constants inbody.py,comfort.pyandcharging.pyTested
2026 R1S (Gen 2), 2026.36.01: locks, windows, frunk, liftgate, seat heat/vent (all rows), steering wheel heat, preconditioning and temp (incl. HI/LO), defrost, charge limit, start/stop charging, charge port, panic, Gear Guard video. Payloads match the Rivian app's (re-captured 2026-11-15).
Not tested: R1T (tailgate), side bins, R2
Overlap with #235
I compared the two on my R1S and the payloads match byte for byte, except LO. #235 has been quiet since, so I'm opening mine. Happy to go with whichever you'd rather merge.