From 0192bdf2dd8b505f3df04f6d3a8f11f13b9f6ceb Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Tue, 10 Nov 2026 04:41:31 +0000 Subject: [PATCH 1/8] Pass subscription errors to an on_error callback 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. --- src/rivian/rivian.py | 5 ++++- src/rivian/ws_monitor.py | 29 ++++++++++++++++++++++++----- tests/test_ws_monitor.py | 22 +++++++++++++++++++++- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/rivian/rivian.py b/src/rivian/rivian.py index c9cd86d..c4854de 100644 --- a/src/rivian/rivian.py +++ b/src/rivian/rivian.py @@ -1136,6 +1136,7 @@ async def _start_subscription( payload: dict[str, Any], callback: Callable[[dict[str, Any]], None], description: str, + on_error: Callable[[dict[str, Any]], None] | None = None, ) -> Callable[[], Awaitable[None]] | None: """Connect the web socket if needed and start a subscription. @@ -1146,7 +1147,9 @@ async def _start_subscription( ws_monitor = await self._ws_connect() # Ends early if the connection closes, e.g. when rate limited if await ws_monitor.wait_for_ack() and ( - unsubscribe := await ws_monitor.start_subscription(payload, callback) + unsubscribe := await ws_monitor.start_subscription( + payload, callback, on_error=on_error + ) ): _LOGGER.debug("Subscribed to %s", description) return unsubscribe diff --git a/src/rivian/ws_monitor.py b/src/rivian/ws_monitor.py index 6e6e77e..bf0a339 100644 --- a/src/rivian/ws_monitor.py +++ b/src/rivian/ws_monitor.py @@ -98,8 +98,14 @@ def __init__( self._monitor_task: asyncio.Task | None = None self._receiver_task: asyncio.Task | None = None self._last_received: datetime | None = None + # id -> (callback, payload, error callback) self._subscriptions: dict[ - str, tuple[Callable[[dict[str, Any]], None], dict[str, Any]] + str, + tuple[ + Callable[[dict[str, Any]], None], + dict[str, Any], + Callable[[dict[str, Any]], None] | None, + ], ] = {} @property @@ -211,13 +217,20 @@ async def wait_for_ack(self) -> bool: return self._connection_ack.is_set() async def start_subscription( - self, payload: dict[str, Any], callback: Callable[[dict[str, Any]], None] + self, + payload: dict[str, Any], + callback: Callable[[dict[str, Any]], None], + on_error: Callable[[dict[str, Any]], None] | None = None, ) -> Callable[[], Awaitable[None]] | None: - """Start a subscription.""" + """Start a subscription. + + `on_error` gets the subscription's error messages, which are otherwise + only logged. + """ if not self.connected: return None _id = str(uuid4()) - self._subscriptions[_id] = (callback, payload) + self._subscriptions[_id] = (callback, payload, on_error) await self._subscribe(_id, payload) async def unsubscribe() -> None: @@ -247,7 +260,7 @@ async def _resubscribe_all(self) -> None: except TimeoutError: _LOGGER.error("A timeout occurred while attempting to resubscribe") return - for _id, (_, payload) in self._subscriptions.items(): + for _id, (_, payload, _) in self._subscriptions.items(): await self._subscribe(_id, payload) async def _receiver(self) -> None: @@ -305,6 +318,12 @@ async def _receive(self, websocket: ClientWebSocketResponse[bool]) -> None: _fn(data) except Exception: # pylint: disable=broad-except _LOGGER.exception("Error in a subscription callback") + elif ( + data_type == "error" + and (subscription := self._subscriptions.get(data.get("id"))) + and subscription[2] + ): + subscription[2](data) else: self._log_message(msg) elif msg.type == WSMsgType.ERROR: diff --git a/tests/test_ws_monitor.py b/tests/test_ws_monitor.py index 7f5a4bd..88d7a52 100644 --- a/tests/test_ws_monitor.py +++ b/tests/test_ws_monitor.py @@ -31,6 +31,7 @@ def __init__(self) -> None: self.ping_once_connections = 0 self.connections = 0 self.next_on_subscribe = False + self.error_on_subscribe = False self.url = "" async def handler(self, request: web.Request) -> web.WebSocketResponse: @@ -72,6 +73,10 @@ async def handler(self, request: web.Request) -> web.WebSocketResponse: data = msg.json() if self.next_on_subscribe and data.get("type") == "subscribe": await ws.send_json({"id": data["id"], "type": "next"}) + if self.error_on_subscribe and data.get("type") == "subscribe": + await ws.send_json( + {"id": data["id"], "type": "error", "payload": [{}]} + ) return ws @@ -159,7 +164,7 @@ async def fake_sleep(delay: float) -> None: def add_subscription(monitor: WebSocketMonitor) -> None: """Give the monitor a subscription to resume, so it keeps reconnecting.""" - monitor._subscriptions["sub"] = (lambda _: None, {"query": "subscription"}) + monitor._subscriptions["sub"] = (lambda _: None, {"query": "subscription"}, None) async def wait_for(condition: Any, timeout: float = 5) -> None: @@ -594,3 +599,18 @@ async def test_monitor_stops_when_the_session_closes( await wait_for(monitor.monitor.done) assert server.connections == 1 assert not [r for r in caplog.records if r.levelname == "ERROR"] + + +async def test_subscription_errors_reach_on_error( + server: FakeServer, monitor: WebSocketMonitor +) -> None: + """A subscription's error message goes to its on_error, if it has one.""" + server.error_on_subscribe = True + await monitor.new_connection(start_monitor=True) + await wait_for(lambda: monitor.connection_ack.is_set()) + errors: list[dict[str, Any]] = [] + await monitor.start_subscription({"query": "a"}, lambda _: None, errors.append) + await monitor.start_subscription({"query": "b"}, lambda _: None) + await wait_for(lambda: errors) + assert errors[0]["type"] == "error" + assert monitor.connected From e8fe7d97e8eb1c4e59ba5e81f4f0da88a2a4c3f7 Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Sun, 15 Nov 2026 18:17:39 +0000 Subject: [PATCH 2/8] Guard the on_error callback like the next callback 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. --- src/rivian/ws_monitor.py | 28 ++++++++++++++++++---------- tests/test_ws_monitor.py | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/rivian/ws_monitor.py b/src/rivian/ws_monitor.py index bf0a339..dd2578d 100644 --- a/src/rivian/ws_monitor.py +++ b/src/rivian/ws_monitor.py @@ -55,6 +55,22 @@ class _Backoff: rate_limited: bool = False # whether the backoff until retry_at is a rate limit +async def _run_callback( + callback: Callable[[dict[str, Any]], None], data: dict[str, Any] +) -> None: + """Run a subscription callback, logging instead of raising if it fails. + + A failing callback shouldn't take the connection down. + """ + try: + if inspect.iscoroutinefunction(callback): + await callback(data) + else: + callback(data) + except Exception: # pylint: disable=broad-except + _LOGGER.exception("Error in a subscription callback") + + class WebSocketMonitor: """Web socket monitor for a vehicle.""" @@ -309,21 +325,13 @@ async def _receive(self, websocket: ClientWebSocketResponse[bool]) -> None: elif data_type == "next": self._reset_backoff() if (_id := data.get("id")) in self._subscriptions: - _fn = self._subscriptions[_id][0] - # A failing callback shouldn't take the connection down - try: - if inspect.iscoroutinefunction(_fn): - await _fn(data) - else: - _fn(data) - except Exception: # pylint: disable=broad-except - _LOGGER.exception("Error in a subscription callback") + await _run_callback(self._subscriptions[_id][0], data) elif ( data_type == "error" and (subscription := self._subscriptions.get(data.get("id"))) and subscription[2] ): - subscription[2](data) + await _run_callback(subscription[2], data) else: self._log_message(msg) elif msg.type == WSMsgType.ERROR: diff --git a/tests/test_ws_monitor.py b/tests/test_ws_monitor.py index 88d7a52..3ea5bbe 100644 --- a/tests/test_ws_monitor.py +++ b/tests/test_ws_monitor.py @@ -614,3 +614,26 @@ async def test_subscription_errors_reach_on_error( await wait_for(lambda: errors) assert errors[0]["type"] == "error" assert monitor.connected + + +async def test_failing_on_error_keeps_connection( + server: FakeServer, + monitor: WebSocketMonitor, + caplog: pytest.LogCaptureFixture, +) -> None: + """An on_error that raises is logged, and later messages still arrive.""" + server.error_on_subscribe = True + await monitor.new_connection(start_monitor=True) + await wait_for(lambda: monitor.connection_ack.is_set()) + + def failing(_: dict[str, Any]) -> None: + raise ValueError("on_error failed") + + errors: list[dict[str, Any]] = [] + await monitor.start_subscription({"query": "a"}, lambda _: None, failing) + await monitor.start_subscription({"query": "b"}, lambda _: None, errors.append) + await wait_for(lambda: errors) + + assert "Error in a subscription callback" in caplog.text + assert monitor.connected + assert server.connections == 1 From 206cf0901d73c64c82716fc40650a24aa860532b Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Tue, 10 Nov 2026 04:41:31 +0000 Subject: [PATCH 3/8] Add starting a Gear Guard live stream `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 #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. --- src/rivian/parallax/__init__.py | 10 +++ src/rivian/parallax/proto/security.proto | 16 +++++ src/rivian/parallax/proto/security_pb2.py | 46 +++++++------ src/rivian/parallax/proto/security_pb2.pyi | 25 +++++++ src/rivian/parallax/security.py | 18 +++++ src/rivian/rivian.py | 78 ++++++++++++++++++++++ tests/parallax/test_security.py | 10 +++ tests/test_rivian.py | 59 ++++++++++++++++ 8 files changed, 241 insertions(+), 21 deletions(-) diff --git a/src/rivian/parallax/__init__.py b/src/rivian/parallax/__init__.py index 530e1a5..b1cdeb4 100644 --- a/src/rivian/parallax/__init__.py +++ b/src/rivian/parallax/__init__.py @@ -19,6 +19,8 @@ Reads a raw `subscribe_for_parallax_command_state` message. encode_end_trip(user_id) -> str Builds the unsigned `end_trip` request. + encode_live_streaming(camera, device_id) -> bytes + A Gear Guard live stream start, for `start_gear_guard_live_stream`. Layout: core.py - registry, payload parsing and shared helpers @@ -68,6 +70,11 @@ ) from .navigation import UPDATED_TRIP_MODEL, encode_end_trip from .operation import encode_vehicle_operation +from .security import ( + GEAR_GUARD_CAMERAS, + START_LIVE_STREAMING_RVM, + encode_live_streaming, +) PARALLAX_RVMS: list[str] = list(RVMDecoder.decoders) @@ -88,8 +95,10 @@ "CHARGING_RVMS", "CLIMATE_HOLD_SETTING_RVM", "CLIMATE_HOLD_STATUS_RVM", + "GEAR_GUARD_CAMERAS", "LOCK_RVM", "PARALLAX_RVMS", + "START_LIVE_STREAMING_RVM", "UNLOCK_RVM", "UPDATED_TRIP_MODEL", "decode_command_state_message", @@ -98,6 +107,7 @@ "encode_climate_hold_setting", "encode_command", "encode_end_trip", + "encode_live_streaming", "encode_lock", "encode_unlock", "encode_vehicle_operation", diff --git a/src/rivian/parallax/proto/security.proto b/src/rivian/parallax/proto/security.proto index cebfd21..0457397 100644 --- a/src/rivian/parallax/proto/security.proto +++ b/src/rivian/parallax/proto/security.proto @@ -129,3 +129,19 @@ enum TosAcceptance { TOS_NOT_ACCEPTED = 1; TOS_ACCEPTED = 2; } + +// security.video_monitoring.start_live_streaming +message LiveStreamingRequest { + GearGuardCamera camera = 1; + string device_id = 2; // a label for the viewer; any stable string works +} + +enum GearGuardCamera { // the app's camera selector + GEAR_GUARD_CAMERA_UNSPECIFIED = 0; + GEAR_GUARD_CAMERA_FRONT = 1; + GEAR_GUARD_CAMERA_BED = 2; + GEAR_GUARD_CAMERA_LEFT = 3; + GEAR_GUARD_CAMERA_RIGHT = 4; + GEAR_GUARD_CAMERA_REAR = 5; + GEAR_GUARD_CAMERA_INTERIOR = 6; +} diff --git a/src/rivian/parallax/proto/security_pb2.py b/src/rivian/parallax/proto/security_pb2.py index 617a4b9..408b1e3 100644 --- a/src/rivian/parallax/proto/security_pb2.py +++ b/src/rivian/parallax/proto/security_pb2.py @@ -24,33 +24,35 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$rivian/parallax/proto/security.proto\x12\x18rivian.parallax.security\"\x0e\n\x0cPassiveEntry\"\xe7\x03\n\x03\x42tm\x12:\n\x02\x66\x66\x18\x01 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x00\x88\x01\x01\x12:\n\x02ic\x18\x02 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x01\x88\x01\x01\x12;\n\x03lfd\x18\x03 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x02\x88\x01\x01\x12:\n\x02rf\x18\x04 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x03\x88\x01\x01\x12;\n\x03rfd\x18\x05 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x04\x88\x01\x01\x12:\n\x02oc\x18\x06 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x05\x88\x01\x01\x12\x11\n\tffr_error\x18\x07 \x01(\x05\x12\x11\n\trfr_error\x18\x08 \x01(\x05\x12\x11\n\tffl_error\x18\t \x01(\x05\x12\x11\n\trfl_error\x18\n \x01(\x05\x42\x05\n\x03_ffB\x05\n\x03_icB\x06\n\x04_lfdB\x05\n\x03_rfB\x06\n\x04_rfdB\x05\n\x03_oc\"_\n\x10ImmobilizerState\x12@\n\x06status\x18\x01 \x01(\x0e\x32+.rivian.parallax.security.ImmobilizerStatusH\x00\x88\x01\x01\x42\t\n\x07_status\"\xba\x01\n\x11PassiveEntryDebug\x12\x45\n\x06reason\x18\x01 \x01(\x0e\x32\x30.rivian.parallax.security.PassiveEntryFailReasonH\x00\x88\x01\x01\x12S\n\x1bsend_lock_fail_notification\x18\x02 \x01(\x0e\x32..rivian.parallax.security.LockFailNotificationB\t\n\x07_reason\"\xbe\x01\n\x08VasFault\x12K\n\x0esecure_element\x18\x01 \x01(\x0e\x32..rivian.parallax.security.SecureElementFaultedH\x00\x88\x01\x01\x12\x43\n\naccess_can\x18\x02 \x01(\x0e\x32*.rivian.parallax.security.AccessCanFaultedH\x01\x88\x01\x01\x42\x11\n\x0f_secure_elementB\r\n\x0b_access_can\"\x8d\x01\n\nAlarmState\x12>\n\x0bsound_alarm\x18\x01 \x01(\x0e\x32$.rivian.parallax.security.AlarmSoundH\x00\x88\x01\x01\x12/\n\'consecutive_alarm_disabled_notification\x18\x02 \x01(\x08\x42\x0e\n\x0c_sound_alarm\"\x81\x02\n\x14VideoMonitoringState\x12\x44\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.security.VideoMonitoringStatusH\x00\x88\x01\x01\x12\x36\n\x04mode\x18\x02 \x01(\x0e\x32#.rivian.parallax.security.VideoModeH\x01\x88\x01\x01\x12\x44\n\x0eterms_accepted\x18\x03 \x01(\x0e\x32\'.rivian.parallax.security.TosAcceptanceH\x02\x88\x01\x01\x42\t\n\x07_statusB\x07\n\x05_modeB\x11\n\x0f_terms_accepted*M\n\x0fHardwareFailure\x12 \n\x1cHARDWARE_FAILURE_UNSPECIFIED\x10\x00\x12\x18\n\x14HARDWARE_FAILURE_SET\x10\x01*v\n\x11ImmobilizerStatus\x12\x1c\n\x18IMMOBILIZER_NOT_ASSIGNED\x10\x00\x12\x1e\n\x1aIMMOBILIZER_NOT_AUTHORIZED\x10\x01\x12#\n\x1fIMMOBILIZER_AUTHORIZED_TO_DRIVE\x10\x02*y\n\x14LockFailNotification\x12\x1e\n\x1aLOCK_FAIL_NOTIFICATION_SNA\x10\x00\x12\x1f\n\x1bLOCK_FAIL_NOTIFICATION_TRUE\x10\x01\x12 \n\x1cLOCK_FAIL_NOTIFICATION_FALSE\x10\x02*\xfe\x03\n\x16PassiveEntryFailReason\x12\"\n\x1ePASSIVE_ENTRY_FAIL_UNSPECIFIED\x10\x00\x12\x1d\n\x19PASSIVE_ENTRY_NOT_IN_PARK\x10\x01\x12!\n\x1dPASSIVE_ENTRY_AT_HOME_DISABLE\x10\x02\x12#\n\x1fPASSIVE_ENTRY_PASSENGER_IN_SEAT\x10\x03\x12$\n PASSIVE_ENTRY_DEVICE_NOT_ENABLED\x10\x04\x12 \n\x1cPASSIVE_ENTRY_TRANSPORT_MODE\x10\x05\x12\x1f\n\x1bPASSIVE_ENTRY_CAR_WASH_MODE\x10\x06\x12\x1b\n\x17PASSIVE_ENTRY_CAMP_MODE\x10\x07\x12\x1c\n\x18PASSIVE_ENTRY_ACTIVE_OTA\x10\x08\x12$\n PASSIVE_ENTRY_SHOW_AND_TELL_MODE\x10\t\x12#\n\x1fPASSIVE_ENTRY_RCVD_RSSI_PENDING\x10\n\x12#\n\x1fPASSIVE_ENTRY_LOCK_ONLY_AT_HOME\x10\x0b\x12\"\n\x1ePASSIVE_ENTRY_CAR_COSTUME_MODE\x10\x0c\x12!\n\x1dPASSIVE_ENTRY_SLEPT_IMMEDIATE\x10\r*\x9b\x02\n\x14SecureElementFaulted\x12$\n SECURE_ELEMENT_FAULT_UNSPECIFIED\x10\x00\x12\x1d\n\x19SECURE_ELEMENT_NO_FAILURE\x10\x01\x12%\n!SECURE_ELEMENT_LOST_COMMUNICATION\x10\x02\x12(\n$SECURE_ELEMENT_APPLET_NOT_PROGRAMMED\x10\x03\x12!\n\x1dSECURE_ELEMENT_NOT_CONFIGURED\x10\x04\x12!\n\x1dSECURE_ELEMENT_ATTACK_COUNTER\x10\x05\x12\'\n#SECURE_ELEMENT_URSK_DECRYPT_FAILURE\x10\x06*g\n\x10\x41\x63\x63\x65ssCanFaulted\x12 \n\x1c\x41\x43\x43\x45SS_CAN_FAULT_UNSPECIFIED\x10\x00\x12\x19\n\x15\x41\x43\x43\x45SS_CAN_NO_FAILURE\x10\x01\x12\x16\n\x12\x41\x43\x43\x45SS_CAN_FAILURE\x10\x02*|\n\nAlarmSound\x12\x1b\n\x17\x41LARM_SOUND_UNSPECIFIED\x10\x00\x12\x15\n\x11\x41LARM_SOUND_FALSE\x10\x01\x12\x14\n\x10\x41LARM_SOUND_TRUE\x10\x02\x12$\n ALARM_SOUND_SIGNAL_NOT_AVAILABLE\x10\x03*\xb8\x01\n\x15VideoMonitoringStatus\x12\'\n#VIDEO_MONITORING_STATUS_UNSPECIFIED\x10\x00\x12\x1d\n\x19VIDEO_MONITORING_DISABLED\x10\x01\x12\x1c\n\x18VIDEO_MONITORING_ENABLED\x10\x02\x12\x1b\n\x17VIDEO_MONITORING_ACTIVE\x10\x03\x12\x1c\n\x18VIDEO_MONITORING_FAULTED\x10\x04*Z\n\tVideoMode\x12\x13\n\x0fVIDEO_MODE_NONE\x10\x00\x12\x19\n\x15VIDEO_MODE_EVERYWHERE\x10\x01\x12\x1d\n\x19VIDEO_MODE_AWAY_FROM_HOME\x10\x02*W\n\rTosAcceptance\x12\x1e\n\x1aTOS_ACCEPTANCE_UNSPECIFIED\x10\x00\x12\x14\n\x10TOS_NOT_ACCEPTED\x10\x01\x12\x10\n\x0cTOS_ACCEPTED\x10\x02\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$rivian/parallax/proto/security.proto\x12\x18rivian.parallax.security\"\x0e\n\x0cPassiveEntry\"\xe7\x03\n\x03\x42tm\x12:\n\x02\x66\x66\x18\x01 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x00\x88\x01\x01\x12:\n\x02ic\x18\x02 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x01\x88\x01\x01\x12;\n\x03lfd\x18\x03 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x02\x88\x01\x01\x12:\n\x02rf\x18\x04 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x03\x88\x01\x01\x12;\n\x03rfd\x18\x05 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x04\x88\x01\x01\x12:\n\x02oc\x18\x06 \x01(\x0e\x32).rivian.parallax.security.HardwareFailureH\x05\x88\x01\x01\x12\x11\n\tffr_error\x18\x07 \x01(\x05\x12\x11\n\trfr_error\x18\x08 \x01(\x05\x12\x11\n\tffl_error\x18\t \x01(\x05\x12\x11\n\trfl_error\x18\n \x01(\x05\x42\x05\n\x03_ffB\x05\n\x03_icB\x06\n\x04_lfdB\x05\n\x03_rfB\x06\n\x04_rfdB\x05\n\x03_oc\"_\n\x10ImmobilizerState\x12@\n\x06status\x18\x01 \x01(\x0e\x32+.rivian.parallax.security.ImmobilizerStatusH\x00\x88\x01\x01\x42\t\n\x07_status\"\xba\x01\n\x11PassiveEntryDebug\x12\x45\n\x06reason\x18\x01 \x01(\x0e\x32\x30.rivian.parallax.security.PassiveEntryFailReasonH\x00\x88\x01\x01\x12S\n\x1bsend_lock_fail_notification\x18\x02 \x01(\x0e\x32..rivian.parallax.security.LockFailNotificationB\t\n\x07_reason\"\xbe\x01\n\x08VasFault\x12K\n\x0esecure_element\x18\x01 \x01(\x0e\x32..rivian.parallax.security.SecureElementFaultedH\x00\x88\x01\x01\x12\x43\n\naccess_can\x18\x02 \x01(\x0e\x32*.rivian.parallax.security.AccessCanFaultedH\x01\x88\x01\x01\x42\x11\n\x0f_secure_elementB\r\n\x0b_access_can\"\x8d\x01\n\nAlarmState\x12>\n\x0bsound_alarm\x18\x01 \x01(\x0e\x32$.rivian.parallax.security.AlarmSoundH\x00\x88\x01\x01\x12/\n\'consecutive_alarm_disabled_notification\x18\x02 \x01(\x08\x42\x0e\n\x0c_sound_alarm\"\x81\x02\n\x14VideoMonitoringState\x12\x44\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.security.VideoMonitoringStatusH\x00\x88\x01\x01\x12\x36\n\x04mode\x18\x02 \x01(\x0e\x32#.rivian.parallax.security.VideoModeH\x01\x88\x01\x01\x12\x44\n\x0eterms_accepted\x18\x03 \x01(\x0e\x32\'.rivian.parallax.security.TosAcceptanceH\x02\x88\x01\x01\x42\t\n\x07_statusB\x07\n\x05_modeB\x11\n\x0f_terms_accepted\"d\n\x14LiveStreamingRequest\x12\x39\n\x06\x63\x61mera\x18\x01 \x01(\x0e\x32).rivian.parallax.security.GearGuardCamera\x12\x11\n\tdevice_id\x18\x02 \x01(\t*M\n\x0fHardwareFailure\x12 \n\x1cHARDWARE_FAILURE_UNSPECIFIED\x10\x00\x12\x18\n\x14HARDWARE_FAILURE_SET\x10\x01*v\n\x11ImmobilizerStatus\x12\x1c\n\x18IMMOBILIZER_NOT_ASSIGNED\x10\x00\x12\x1e\n\x1aIMMOBILIZER_NOT_AUTHORIZED\x10\x01\x12#\n\x1fIMMOBILIZER_AUTHORIZED_TO_DRIVE\x10\x02*y\n\x14LockFailNotification\x12\x1e\n\x1aLOCK_FAIL_NOTIFICATION_SNA\x10\x00\x12\x1f\n\x1bLOCK_FAIL_NOTIFICATION_TRUE\x10\x01\x12 \n\x1cLOCK_FAIL_NOTIFICATION_FALSE\x10\x02*\xfe\x03\n\x16PassiveEntryFailReason\x12\"\n\x1ePASSIVE_ENTRY_FAIL_UNSPECIFIED\x10\x00\x12\x1d\n\x19PASSIVE_ENTRY_NOT_IN_PARK\x10\x01\x12!\n\x1dPASSIVE_ENTRY_AT_HOME_DISABLE\x10\x02\x12#\n\x1fPASSIVE_ENTRY_PASSENGER_IN_SEAT\x10\x03\x12$\n PASSIVE_ENTRY_DEVICE_NOT_ENABLED\x10\x04\x12 \n\x1cPASSIVE_ENTRY_TRANSPORT_MODE\x10\x05\x12\x1f\n\x1bPASSIVE_ENTRY_CAR_WASH_MODE\x10\x06\x12\x1b\n\x17PASSIVE_ENTRY_CAMP_MODE\x10\x07\x12\x1c\n\x18PASSIVE_ENTRY_ACTIVE_OTA\x10\x08\x12$\n PASSIVE_ENTRY_SHOW_AND_TELL_MODE\x10\t\x12#\n\x1fPASSIVE_ENTRY_RCVD_RSSI_PENDING\x10\n\x12#\n\x1fPASSIVE_ENTRY_LOCK_ONLY_AT_HOME\x10\x0b\x12\"\n\x1ePASSIVE_ENTRY_CAR_COSTUME_MODE\x10\x0c\x12!\n\x1dPASSIVE_ENTRY_SLEPT_IMMEDIATE\x10\r*\x9b\x02\n\x14SecureElementFaulted\x12$\n SECURE_ELEMENT_FAULT_UNSPECIFIED\x10\x00\x12\x1d\n\x19SECURE_ELEMENT_NO_FAILURE\x10\x01\x12%\n!SECURE_ELEMENT_LOST_COMMUNICATION\x10\x02\x12(\n$SECURE_ELEMENT_APPLET_NOT_PROGRAMMED\x10\x03\x12!\n\x1dSECURE_ELEMENT_NOT_CONFIGURED\x10\x04\x12!\n\x1dSECURE_ELEMENT_ATTACK_COUNTER\x10\x05\x12\'\n#SECURE_ELEMENT_URSK_DECRYPT_FAILURE\x10\x06*g\n\x10\x41\x63\x63\x65ssCanFaulted\x12 \n\x1c\x41\x43\x43\x45SS_CAN_FAULT_UNSPECIFIED\x10\x00\x12\x19\n\x15\x41\x43\x43\x45SS_CAN_NO_FAILURE\x10\x01\x12\x16\n\x12\x41\x43\x43\x45SS_CAN_FAILURE\x10\x02*|\n\nAlarmSound\x12\x1b\n\x17\x41LARM_SOUND_UNSPECIFIED\x10\x00\x12\x15\n\x11\x41LARM_SOUND_FALSE\x10\x01\x12\x14\n\x10\x41LARM_SOUND_TRUE\x10\x02\x12$\n ALARM_SOUND_SIGNAL_NOT_AVAILABLE\x10\x03*\xb8\x01\n\x15VideoMonitoringStatus\x12\'\n#VIDEO_MONITORING_STATUS_UNSPECIFIED\x10\x00\x12\x1d\n\x19VIDEO_MONITORING_DISABLED\x10\x01\x12\x1c\n\x18VIDEO_MONITORING_ENABLED\x10\x02\x12\x1b\n\x17VIDEO_MONITORING_ACTIVE\x10\x03\x12\x1c\n\x18VIDEO_MONITORING_FAULTED\x10\x04*Z\n\tVideoMode\x12\x13\n\x0fVIDEO_MODE_NONE\x10\x00\x12\x19\n\x15VIDEO_MODE_EVERYWHERE\x10\x01\x12\x1d\n\x19VIDEO_MODE_AWAY_FROM_HOME\x10\x02*W\n\rTosAcceptance\x12\x1e\n\x1aTOS_ACCEPTANCE_UNSPECIFIED\x10\x00\x12\x14\n\x10TOS_NOT_ACCEPTED\x10\x01\x12\x10\n\x0cTOS_ACCEPTED\x10\x02*\xe1\x01\n\x0fGearGuardCamera\x12!\n\x1dGEAR_GUARD_CAMERA_UNSPECIFIED\x10\x00\x12\x1b\n\x17GEAR_GUARD_CAMERA_FRONT\x10\x01\x12\x19\n\x15GEAR_GUARD_CAMERA_BED\x10\x02\x12\x1a\n\x16GEAR_GUARD_CAMERA_LEFT\x10\x03\x12\x1b\n\x17GEAR_GUARD_CAMERA_RIGHT\x10\x04\x12\x1a\n\x16GEAR_GUARD_CAMERA_REAR\x10\x05\x12\x1e\n\x1aGEAR_GUARD_CAMERA_INTERIOR\x10\x06\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rivian.parallax.proto.security_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None - _globals['_HARDWAREFAILURE']._serialized_start=1455 - _globals['_HARDWAREFAILURE']._serialized_end=1532 - _globals['_IMMOBILIZERSTATUS']._serialized_start=1534 - _globals['_IMMOBILIZERSTATUS']._serialized_end=1652 - _globals['_LOCKFAILNOTIFICATION']._serialized_start=1654 - _globals['_LOCKFAILNOTIFICATION']._serialized_end=1775 - _globals['_PASSIVEENTRYFAILREASON']._serialized_start=1778 - _globals['_PASSIVEENTRYFAILREASON']._serialized_end=2288 - _globals['_SECUREELEMENTFAULTED']._serialized_start=2291 - _globals['_SECUREELEMENTFAULTED']._serialized_end=2574 - _globals['_ACCESSCANFAULTED']._serialized_start=2576 - _globals['_ACCESSCANFAULTED']._serialized_end=2679 - _globals['_ALARMSOUND']._serialized_start=2681 - _globals['_ALARMSOUND']._serialized_end=2805 - _globals['_VIDEOMONITORINGSTATUS']._serialized_start=2808 - _globals['_VIDEOMONITORINGSTATUS']._serialized_end=2992 - _globals['_VIDEOMODE']._serialized_start=2994 - _globals['_VIDEOMODE']._serialized_end=3084 - _globals['_TOSACCEPTANCE']._serialized_start=3086 - _globals['_TOSACCEPTANCE']._serialized_end=3173 + _globals['_HARDWAREFAILURE']._serialized_start=1557 + _globals['_HARDWAREFAILURE']._serialized_end=1634 + _globals['_IMMOBILIZERSTATUS']._serialized_start=1636 + _globals['_IMMOBILIZERSTATUS']._serialized_end=1754 + _globals['_LOCKFAILNOTIFICATION']._serialized_start=1756 + _globals['_LOCKFAILNOTIFICATION']._serialized_end=1877 + _globals['_PASSIVEENTRYFAILREASON']._serialized_start=1880 + _globals['_PASSIVEENTRYFAILREASON']._serialized_end=2390 + _globals['_SECUREELEMENTFAULTED']._serialized_start=2393 + _globals['_SECUREELEMENTFAULTED']._serialized_end=2676 + _globals['_ACCESSCANFAULTED']._serialized_start=2678 + _globals['_ACCESSCANFAULTED']._serialized_end=2781 + _globals['_ALARMSOUND']._serialized_start=2783 + _globals['_ALARMSOUND']._serialized_end=2907 + _globals['_VIDEOMONITORINGSTATUS']._serialized_start=2910 + _globals['_VIDEOMONITORINGSTATUS']._serialized_end=3094 + _globals['_VIDEOMODE']._serialized_start=3096 + _globals['_VIDEOMODE']._serialized_end=3186 + _globals['_TOSACCEPTANCE']._serialized_start=3188 + _globals['_TOSACCEPTANCE']._serialized_end=3275 + _globals['_GEARGUARDCAMERA']._serialized_start=3278 + _globals['_GEARGUARDCAMERA']._serialized_end=3503 _globals['_PASSIVEENTRY']._serialized_start=66 _globals['_PASSIVEENTRY']._serialized_end=80 _globals['_BTM']._serialized_start=83 @@ -65,4 +67,6 @@ _globals['_ALARMSTATE']._serialized_end=1193 _globals['_VIDEOMONITORINGSTATE']._serialized_start=1196 _globals['_VIDEOMONITORINGSTATE']._serialized_end=1453 + _globals['_LIVESTREAMINGREQUEST']._serialized_start=1455 + _globals['_LIVESTREAMINGREQUEST']._serialized_end=1555 # @@protoc_insertion_point(module_scope) diff --git a/src/rivian/parallax/proto/security_pb2.pyi b/src/rivian/parallax/proto/security_pb2.pyi index 58cc421..e04e8c7 100644 --- a/src/rivian/parallax/proto/security_pb2.pyi +++ b/src/rivian/parallax/proto/security_pb2.pyi @@ -81,6 +81,16 @@ class TosAcceptance(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): TOS_ACCEPTANCE_UNSPECIFIED: _ClassVar[TosAcceptance] TOS_NOT_ACCEPTED: _ClassVar[TosAcceptance] TOS_ACCEPTED: _ClassVar[TosAcceptance] + +class GearGuardCamera(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + GEAR_GUARD_CAMERA_UNSPECIFIED: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_FRONT: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_BED: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_LEFT: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_RIGHT: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_REAR: _ClassVar[GearGuardCamera] + GEAR_GUARD_CAMERA_INTERIOR: _ClassVar[GearGuardCamera] HARDWARE_FAILURE_UNSPECIFIED: HardwareFailure HARDWARE_FAILURE_SET: HardwareFailure IMMOBILIZER_NOT_ASSIGNED: ImmobilizerStatus @@ -128,6 +138,13 @@ VIDEO_MODE_AWAY_FROM_HOME: VideoMode TOS_ACCEPTANCE_UNSPECIFIED: TosAcceptance TOS_NOT_ACCEPTED: TosAcceptance TOS_ACCEPTED: TosAcceptance +GEAR_GUARD_CAMERA_UNSPECIFIED: GearGuardCamera +GEAR_GUARD_CAMERA_FRONT: GearGuardCamera +GEAR_GUARD_CAMERA_BED: GearGuardCamera +GEAR_GUARD_CAMERA_LEFT: GearGuardCamera +GEAR_GUARD_CAMERA_RIGHT: GearGuardCamera +GEAR_GUARD_CAMERA_REAR: GearGuardCamera +GEAR_GUARD_CAMERA_INTERIOR: GearGuardCamera class PassiveEntry(_message.Message): __slots__ = () @@ -196,3 +213,11 @@ class VideoMonitoringState(_message.Message): mode: VideoMode terms_accepted: TosAcceptance def __init__(self, status: _Optional[_Union[VideoMonitoringStatus, str]] = ..., mode: _Optional[_Union[VideoMode, str]] = ..., terms_accepted: _Optional[_Union[TosAcceptance, str]] = ...) -> None: ... + +class LiveStreamingRequest(_message.Message): + __slots__ = ("camera", "device_id") + CAMERA_FIELD_NUMBER: _ClassVar[int] + DEVICE_ID_FIELD_NUMBER: _ClassVar[int] + camera: GearGuardCamera + device_id: str + def __init__(self, camera: _Optional[_Union[GearGuardCamera, str]] = ..., device_id: _Optional[str] = ...) -> None: ... diff --git a/src/rivian/parallax/security.py b/src/rivian/parallax/security.py index bce9291..c0f40fb 100644 --- a/src/rivian/parallax/security.py +++ b/src/rivian/parallax/security.py @@ -7,6 +7,24 @@ from .core import RVMDecoder, _enum, _present from .proto import security_pb2 +START_LIVE_STREAMING_RVM: Final = "security.video_monitoring.start_live_streaming" + +GEAR_GUARD_CAMERAS: Final[dict[str, security_pb2.GearGuardCamera]] = { + "front": security_pb2.GEAR_GUARD_CAMERA_FRONT, + "bed": security_pb2.GEAR_GUARD_CAMERA_BED, + "left": security_pb2.GEAR_GUARD_CAMERA_LEFT, + "right": security_pb2.GEAR_GUARD_CAMERA_RIGHT, + "rear": security_pb2.GEAR_GUARD_CAMERA_REAR, + "interior": security_pb2.GEAR_GUARD_CAMERA_INTERIOR, +} + + +def encode_live_streaming(camera: str, device_id: str) -> bytes: + """Encode a security.video_monitoring.start_live_streaming payload.""" + return security_pb2.LiveStreamingRequest( + camera=GEAR_GUARD_CAMERAS[camera], device_id=device_id + ).SerializeToString() + @RVMDecoder.register("security.access.passive_entry", security_pb2.PassiveEntry) def decode_passive_entry(_m: security_pb2.PassiveEntry) -> dict[str, Any]: diff --git a/src/rivian/rivian.py b/src/rivian/rivian.py index c4854de..a2166f4 100644 --- a/src/rivian/rivian.py +++ b/src/rivian/rivian.py @@ -34,10 +34,13 @@ from .parallax import ( CLIMATE_HOLD_SETTING_RVM, CLIMATE_HOLD_STATUS_RVM, + GEAR_GUARD_CAMERAS, + START_LIVE_STREAMING_RVM, UPDATED_TRIP_MODEL, encode_climate_hold_setting, encode_command, encode_end_trip, + encode_live_streaming, encode_vehicle_operation, ) from .utils import generate_vehicle_command_hmac, send_deprecation_warning @@ -789,6 +792,81 @@ async def end_trip(self, vehicle_id: str, user_id: str) -> bool: ) return False + async def start_gear_guard_live_stream( + self, + vehicle_id: str, + camera: str = "front", + *, + identity_id: str, + vehicle_key: str, + private_key: str, + device_id: str = "rivian-python-client", + timeout: float = 40, + ) -> dict[str, Any] | None: + """Start a Gear Guard live stream and return its Kinesis WebRTC config. + + `camera` is a `parallax.GEAR_GUARD_CAMERAS` key. Needs Gear Guard video + monitoring on and a paired phone; the vehicle serves one viewer at a time, + about 3 minutes each and an hour a day. None if the start fails or no config + arrives within `timeout` seconds (a sleeping vehicle may need longer). + Raises RivianApiException if the vehicle refuses the stream, e.g. for a + camera it doesn't have. + """ + if camera not in GEAR_GUARD_CAMERAS: + raise RivianBadRequestError(f"Unknown camera: {camera}") + command_id = str(uuid.uuid4()) + config: asyncio.Future[dict[str, Any]] = ( + asyncio.get_running_loop().create_future() + ) + + def on_message(message: dict[str, Any]) -> None: + data = (message.get("payload") or {}).get("data") or {} + live = data.get("gearGuardLiveConfig") or {} + if live.get("endpoint") and not config.done(): + config.set_result(live) + + def on_error(message: dict[str, Any]) -> None: + errors = message.get("payload") or [{}] + reason = (errors[0].get("extensions") or {}).get("reason") + if not config.done(): + config.set_exception( + RivianApiException(f"The vehicle refused the stream: {reason}") + ) + + # The cloud sends the config to the subscription whose commandId is the + # start command's id, as hex + unsubscribe = await self._start_subscription( + { + "operationName": "GearGuardLiveConfigSubscription", + "query": "subscription GearGuardLiveConfigSubscription($vehicleId: String!, $commandId: String!) { gearGuardLiveConfig(vehicleId: $vehicleId, commandId: $commandId) { __typename endpoint channelArn role iceServers { __typename url username credential ttl } } }", + "variables": { + "vehicleId": vehicle_id, + "commandId": uuid.UUID(command_id).hex, + }, + }, + on_message, + f"{vehicle_id} Gear Guard live config", + on_error, + ) + if not unsubscribe: + return None + try: + if not await self.send_parallax_command( + vehicle_id, + START_LIVE_STREAMING_RVM, + encode_live_streaming(camera, device_id), + identity_id=identity_id, + vehicle_key=vehicle_key, + private_key=private_key, + command_id=command_id, + ): + return None + return await asyncio.wait_for(config, timeout) + except TimeoutError: + return None + finally: + await unsubscribe() + async def get_vehicle_ota_update_details(self, vehicle_id: str) -> ClientResponse: """Get vehicle OTA update details.""" url = GRAPHQL_GATEWAY diff --git a/tests/parallax/test_security.py b/tests/parallax/test_security.py index 1864196..7c5189d 100644 --- a/tests/parallax/test_security.py +++ b/tests/parallax/test_security.py @@ -2,6 +2,7 @@ from __future__ import annotations +from rivian.parallax import encode_live_streaming from rivian.parallax.proto import security_pb2 as security from .helpers import decode @@ -35,3 +36,12 @@ def test_alarm_state() -> None: "alarmSoundStatus": "false", "consecutiveAlarmDisabledNotification": True, } + + +def test_encode_live_streaming() -> None: + """A live stream start names the camera and the viewer's device id.""" + request = security.LiveStreamingRequest.FromString( + encode_live_streaming("rear", "viewer") + ) + assert request.camera == security.GEAR_GUARD_CAMERA_REAR + assert request.device_id == "viewer" diff --git a/tests/test_rivian.py b/tests/test_rivian.py index d72c83f..0bdccbb 100644 --- a/tests/test_rivian.py +++ b/tests/test_rivian.py @@ -495,6 +495,65 @@ async def test_trips(aresponses: ResponsesMockServer) -> None: assert not await rivian.end_trip("vehicle_id", "user") +async def test_start_gear_guard_live_stream(aresponses: ResponsesMockServer) -> None: + """Test starting a Gear Guard live stream.""" + requests = capture_requests( + aresponses, + SEND_PARALLAX_COMMAND_RESPONSE, + {"data": {"sendParallaxPayload": None}}, + SEND_PARALLAX_COMMAND_RESPONSE, + ) + vehicle_key, private_key = generate_key_pair() + keys = { + "identity_id": "identity_id", + "vehicle_key": vehicle_key, + "private_key": private_key, + } + live = {"endpoint": "wss://kinesis", "role": "VIEWER", "iceServers": []} + async with aiohttp.ClientSession(): + rivian = Rivian( + csrf_token="csrf", + app_session_token="token", + user_session_token="token", + ) + subscriptions: list[dict[str, Any]] = [] + unsubscribe = AsyncMock() + + async def subscribe( + payload: dict[str, Any], callback: Any, _: str, on_error: Any + ) -> Any: + subscriptions.append(payload) + callback({"payload": {"data": {"gearGuardLiveConfig": live}}}) + return unsubscribe + + rivian._start_subscription = subscribe # type: ignore[method-assign] + config = await rivian.start_gear_guard_live_stream("vehicle_id", "rear", **keys) + assert config == live + _, operation = decode_parallax_command(requests[0]) + assert operation.rvm == "security.video_monitoring.start_live_streaming" + # The config is routed by the start command's id + assert subscriptions[0]["variables"]["commandId"] == operation.command_id.hex() + + # A rejected start returns None and still ends the subscription + assert not await rivian.start_gear_guard_live_stream("vehicle_id", **keys) + assert unsubscribe.await_count == 2 + with pytest.raises(RivianBadRequestError): + await rivian.start_gear_guard_live_stream("vehicle_id", "roof", **keys) + + # A refused start fails straight away instead of timing out + async def refuse( + payload: dict[str, Any], callback: Any, _: str, on_error: Any + ) -> Any: + on_error( + {"payload": [{"extensions": {"reason": "VEHICLE_COMMAND_FORBIDDEN"}}]} + ) + return unsubscribe + + rivian._start_subscription = refuse # type: ignore[method-assign] + with pytest.raises(RivianApiException, match="VEHICLE_COMMAND_FORBIDDEN"): + await rivian.start_gear_guard_live_stream("vehicle_id", timeout=30, **keys) + + async def test_subscribe_for_departure_schedules() -> None: """Test subscribing to departure schedules.""" rivian = Rivian(user_session_token="token") From 9124f99840e6a7e4394d28443727e3de8694224e Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Sun, 15 Nov 2026 18:33:00 +0000 Subject: [PATCH 4/8] Read a Gear Guard refusal on early returns and take any error shape 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. --- src/rivian/rivian.py | 8 ++++++-- tests/test_rivian.py | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/rivian/rivian.py b/src/rivian/rivian.py index a2166f4..dc1b05e 100644 --- a/src/rivian/rivian.py +++ b/src/rivian/rivian.py @@ -826,8 +826,9 @@ def on_message(message: dict[str, Any]) -> None: config.set_result(live) def on_error(message: dict[str, Any]) -> None: - errors = message.get("payload") or [{}] - reason = (errors[0].get("extensions") or {}).get("reason") + payload = message.get("payload") or [{}] + error = (payload if isinstance(payload, list) else [payload])[0] + reason = (error.get("extensions") or {}).get("reason") if not config.done(): config.set_exception( RivianApiException(f"The vehicle refused the stream: {reason}") @@ -866,6 +867,9 @@ def on_error(message: dict[str, Any]) -> None: return None finally: await unsubscribe() + # Read a refusal left on the future by an early return, or asyncio logs it + if config.done() and not config.cancelled(): + config.exception() async def get_vehicle_ota_update_details(self, vehicle_id: str) -> ClientResponse: """Get vehicle OTA update details.""" diff --git a/tests/test_rivian.py b/tests/test_rivian.py index 0bdccbb..83e512b 100644 --- a/tests/test_rivian.py +++ b/tests/test_rivian.py @@ -3,7 +3,9 @@ # pylint: disable=protected-access from __future__ import annotations +import asyncio import base64 +import gc import json import uuid from datetime import UTC, date, datetime @@ -502,6 +504,8 @@ async def test_start_gear_guard_live_stream(aresponses: ResponsesMockServer) -> SEND_PARALLAX_COMMAND_RESPONSE, {"data": {"sendParallaxPayload": None}}, SEND_PARALLAX_COMMAND_RESPONSE, + SEND_PARALLAX_COMMAND_RESPONSE, + {"data": {"sendParallaxPayload": None}}, ) vehicle_key, private_key = generate_key_pair() keys = { @@ -553,6 +557,29 @@ async def refuse( with pytest.raises(RivianApiException, match="VEHICLE_COMMAND_FORBIDDEN"): await rivian.start_gear_guard_live_stream("vehicle_id", timeout=30, **keys) + # An error payload sent as an object instead of a list still fails the start + async def refuse_object( + payload: dict[str, Any], callback: Any, _: str, on_error: Any + ) -> Any: + on_error({"payload": {"extensions": {"reason": "VEHICLE_ASLEEP"}}}) + return unsubscribe + + rivian._start_subscription = refuse_object # type: ignore[method-assign] + with pytest.raises(RivianApiException, match="VEHICLE_ASLEEP"): + await rivian.start_gear_guard_live_stream("vehicle_id", timeout=30, **keys) + + # A refusal before a rejected start is read, so asyncio doesn't log it + loop = asyncio.get_running_loop() + unread: list[dict[str, Any]] = [] + loop.set_exception_handler(lambda _, context: unread.append(context)) + try: + rivian._start_subscription = refuse # type: ignore[method-assign] + assert not await rivian.start_gear_guard_live_stream("vehicle_id", **keys) + gc.collect() + finally: + loop.set_exception_handler(None) + assert not unread + async def test_subscribe_for_departure_schedules() -> None: """Test subscribing to departure schedules.""" From 05a5b2ebbe2bc81377849875b4a4383acb154ecc Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Tue, 10 Nov 2026 04:55:09 +0000 Subject: [PATCH 5/8] Add searching for places - `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. --- src/rivian/rivian.py | 61 ++++++++++++++++++++++++++++++++++++++++++++ src/rivian/utils.py | 28 ++++++++++++++++++++ tests/responses.py | 19 ++++++++++++++ tests/test_rivian.py | 44 ++++++++++++++++++++++++++++++++ tests/test_utils.py | 9 +++++++ 5 files changed, 161 insertions(+) diff --git a/src/rivian/rivian.py b/src/rivian/rivian.py index dc1b05e..1501f04 100644 --- a/src/rivian/rivian.py +++ b/src/rivian/rivian.py @@ -666,6 +666,67 @@ async def depart_now( } return await self.__graphql_query(headers, url, graphql_json) + async def search_places( + self, query: str, latitude: float, longitude: float + ) -> list[dict[str, Any]]: + """Search for places like the Rivian app's map search. + + Results come in the search's own order, each with a Google place `id`, + `name`, `location` and the `driveDetails` from `latitude`, `longitude`. + """ + url = GRAPHQL_GATEWAY + headers = BASE_HEADERS | { + "Csrf-Token": self._csrf_token, + "A-Sess": self._app_session_token, + "U-Sess": self._user_session_token, + } + graphql_json = { + "operationName": "places", + "query": "query places($params: PlacesQueryParams!) { places(params: $params) { results { id name location { formattedAddress coordinate { latitude longitude } navCoordinate { latitude longitude } } driveDetails { driveDistance driveDuration } } } }", + "variables": { + "params": { + "query": query, + "userLocation": {"latitude": latitude, "longitude": longitude}, + "autocomplete": "None", + } + }, + } + + response = await self.__graphql_query(headers, url, graphql_json) + if response.status == 200: + data = await response.json() + return (data.get("data", {}).get("places") or {}).get("results") or [] + return [] + + async def suggest_places( + self, query: str, latitude: float, longitude: float + ) -> list[str]: + """Suggest search texts for partial text, for type-ahead in a place search.""" + url = GRAPHQL_GATEWAY + headers = BASE_HEADERS | { + "Csrf-Token": self._csrf_token, + "A-Sess": self._app_session_token, + "U-Sess": self._user_session_token, + } + graphql_json = { + "operationName": "places", + "query": "query places($params: PlacesQueryParams!) { places(params: $params) { queryPredictions { query } } }", + "variables": { + "params": { + "query": query, + "userLocation": {"latitude": latitude, "longitude": longitude}, + "autocomplete": "Place", + } + }, + } + + response = await self.__graphql_query(headers, url, graphql_json) + if response.status == 200: + data = await response.json() + places = data.get("data", {}).get("places") or {} + return [p["query"] for p in places.get("queryPredictions") or []] + return [] + async def send_location_to_vehicle( self, vehicle_id: str, location: str ) -> ClientResponse: diff --git a/src/rivian/utils.py b/src/rivian/utils.py index 1bfff46..d94ac55 100644 --- a/src/rivian/utils.py +++ b/src/rivian/utils.py @@ -8,6 +8,7 @@ from base64 import b64decode, b64encode from datetime import UTC, datetime from typing import cast +from urllib.parse import urlencode from warnings import warn from cryptography.hazmat.primitives import hashes, serialization @@ -143,3 +144,30 @@ def from_epoch(epoch: float) -> datetime: if abs(epoch) >= _MS_THRESHOLD: epoch /= 1000 return datetime.fromtimestamp(epoch, UTC) + + +def place_url( + place_id: str, + name: str, + latitude: float, + longitude: float, + address: str | None = None, +) -> str: + """Return the Rivian app's link for a place, for `send_location_to_vehicle`. + + The vehicle shows the place's name. `place_id` is a Google place id, such as a + `search_places` result's `id`; Rivian refuses these links without one. Use the + result's `navCoordinate`, where the drive ends. + """ + coordinates = f"{latitude},{longitude}" + query = { + "geo_coordinates": coordinates, + "entity_id": place_id, + "name": name, + "nav_coordinates": coordinates, + "address": address, + "source_type": "telenav", + } + return "https://telenav.id/entity?" + urlencode( + {k: v for k, v in query.items() if v is not None} + ) diff --git a/tests/responses.py b/tests/responses.py index 53e98e9..c885a93 100644 --- a/tests/responses.py +++ b/tests/responses.py @@ -654,6 +654,25 @@ "data": {"sendParallaxPayload": {"success": True, "sequenceNumber": 0}} } +PLACES_RESPONSE = { + "data": { + "places": { + "results": [ + { + "id": "place_id", + "name": "REI", + "location": { + "formattedAddress": "5901 Mills Civic Pkwy, West Des Moines, IA", + "coordinate": {"latitude": 41.56028, "longitude": -93.78724}, + "navCoordinate": {"latitude": 41.56001, "longitude": -93.7873}, + }, + "driveDetails": {"driveDistance": 239062, "driveDuration": 9960}, + } + ] + } + } +} + SEND_VEHICLE_OPERATION_RESPONSE = { "data": { "sendVehicleOperation": { diff --git a/tests/test_rivian.py b/tests/test_rivian.py index 83e512b..003e255 100644 --- a/tests/test_rivian.py +++ b/tests/test_rivian.py @@ -45,6 +45,7 @@ DELETE_DEPARTURE_SCHEDULE_RESPONSE, DEPART_NOW_RESPONSE, OTP_TOKEN_RESPONSE, + PLACES_RESPONSE, SEND_LOCATION_TO_VEHICLE_RESPONSE, SEND_PARALLAX_COMMAND_RESPONSE, SEND_VEHICLE_OPERATION_RESPONSE, @@ -581,6 +582,49 @@ async def refuse_object( assert not unread +async def test_search_places(aresponses: ResponsesMockServer) -> None: + """Test searching for places.""" + requests = capture_requests(aresponses, PLACES_RESPONSE, {"data": {"places": None}}) + async with aiohttp.ClientSession(): + rivian = Rivian( + csrf_token="csrf", + app_session_token="token", + user_session_token="token", + ) + + results = await rivian.search_places("REI", 40.175, -92.591) + assert results == PLACES_RESPONSE["data"]["places"]["results"] + assert requests[0]["variables"]["params"] == { + "query": "REI", + "userLocation": {"latitude": 40.175, "longitude": -92.591}, + "autocomplete": "None", + } + assert await rivian.search_places("REI", 40.175, -92.591) == [] + + +async def test_suggest_places(aresponses: ResponsesMockServer) -> None: + """Test suggesting search texts for partial text.""" + predictions = [{"query": "restaurants"}, {"query": "Red Lobster"}] + requests = capture_requests( + aresponses, + {"data": {"places": {"queryPredictions": predictions}}}, + {"data": {"places": None}}, + ) + async with aiohttp.ClientSession(): + rivian = Rivian( + csrf_token="csrf", + app_session_token="token", + user_session_token="token", + ) + + assert await rivian.suggest_places("RE", 40.175, -92.591) == [ + "restaurants", + "Red Lobster", + ] + assert requests[0]["variables"]["params"]["autocomplete"] == "Place" + assert await rivian.suggest_places("RE", 40.175, -92.591) == [] + + async def test_subscribe_for_departure_schedules() -> None: """Test subscribing to departure schedules.""" rivian = Rivian(user_session_token="token") diff --git a/tests/test_utils.py b/tests/test_utils.py index 06fdf4b..0f32d75 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -48,3 +48,12 @@ def test_generate_vehicle_command_hmac() -> None: command, timestamp, VEHICLE_KEY, PRIVATE_KEY ) assert hmac == "2a68bdda69ff8643e37bac595905f6a481435e00bb63bdd415ecbb425a5bb598" + + +def test_place_url() -> None: + """A place link carries the place's name, id, address and coordinates.""" + assert utils.place_url("place_id", "REI", 41.5, -93.7, "1 Main St") == ( + "https://telenav.id/entity?geo_coordinates=41.5%2C-93.7&entity_id=place_id" + "&name=REI&nav_coordinates=41.5%2C-93.7&address=1+Main+St&source_type=telenav" + ) + assert "address" not in utils.place_url("place_id", "REI", 41.5, -93.7) From 5a924ddb600fd9376925a4752576db7d85ce13d7 Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Sun, 8 Nov 2026 02:21:35 +0000 Subject: [PATCH 6/8] Add climate hold and pet mode commands 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. --- src/rivian/parallax/__init__.py | 11 ++++ src/rivian/parallax/comfort.py | 14 ++++ src/rivian/parallax/proto/comfort.proto | 12 ++++ src/rivian/parallax/proto/comfort_pb2.py | 78 ++++++++++++----------- src/rivian/parallax/proto/comfort_pb2.pyi | 15 +++++ tests/parallax/test_comfort.py | 13 +++- 6 files changed, 105 insertions(+), 38 deletions(-) diff --git a/src/rivian/parallax/__init__.py b/src/rivian/parallax/__init__.py index b1cdeb4..1d28390 100644 --- a/src/rivian/parallax/__init__.py +++ b/src/rivian/parallax/__init__.py @@ -21,6 +21,9 @@ Builds the unsigned `end_trip` request. encode_live_streaming(camera, device_id) -> bytes A Gear Guard live stream start, for `start_gear_guard_live_stream`. + encode_climate_hold(on), encode_pet_mode(on) -> bytes + Payloads for the signed SET_CLIMATE_HOLD_RVM and SET_PET_MODE_RVM + commands. Layout: core.py - registry, payload parsing and shared helpers @@ -60,7 +63,11 @@ from .comfort import ( CLIMATE_HOLD_SETTING_RVM, CLIMATE_HOLD_STATUS_RVM, + SET_CLIMATE_HOLD_RVM, + SET_PET_MODE_RVM, + encode_climate_hold, encode_climate_hold_setting, + encode_pet_mode, ) from .command import decode_command_state_message, encode_command from .core import ( @@ -98,17 +105,21 @@ "GEAR_GUARD_CAMERAS", "LOCK_RVM", "PARALLAX_RVMS", + "SET_CLIMATE_HOLD_RVM", + "SET_PET_MODE_RVM", "START_LIVE_STREAMING_RVM", "UNLOCK_RVM", "UPDATED_TRIP_MODEL", "decode_command_state_message", "decode_parallax_message", "decode_parallax_subscription_message", + "encode_climate_hold", "encode_climate_hold_setting", "encode_command", "encode_end_trip", "encode_live_streaming", "encode_lock", + "encode_pet_mode", "encode_unlock", "encode_vehicle_operation", ] diff --git a/src/rivian/parallax/comfort.py b/src/rivian/parallax/comfort.py index 279613d..da6f64f 100644 --- a/src/rivian/parallax/comfort.py +++ b/src/rivian/parallax/comfort.py @@ -9,6 +9,8 @@ CLIMATE_HOLD_SETTING_RVM: Final = "comfort.cabin.climate_hold_setting" CLIMATE_HOLD_STATUS_RVM: Final = "comfort.cabin.climate_hold_status" +SET_CLIMATE_HOLD_RVM: Final = "comfort.cabin.set_climate_hold" +SET_PET_MODE_RVM: Final = "comfort.cabin.set_pet_mode" @RVMDecoder.register( @@ -208,6 +210,18 @@ def encode_climate_hold_setting(duration_seconds: int) -> bytes: return comfort_pb2.ClimateHoldSetting(duration=duration_seconds).SerializeToString() +def encode_climate_hold(on: bool) -> bytes: + """Encode a comfort.cabin.set_climate_hold payload.""" + action = comfort_pb2.ACTION_ON if on else comfort_pb2.ACTION_OFF + return comfort_pb2.ActionRequest(action=action).SerializeToString() + + +def encode_pet_mode(on: bool) -> bytes: + """Encode a comfort.cabin.set_pet_mode payload.""" + action = comfort_pb2.ACTION_ON if on else comfort_pb2.ACTION_OFF + return comfort_pb2.ActionRequest(action=action).SerializeToString() + + @RVMDecoder.register(CLIMATE_HOLD_SETTING_RVM, comfort_pb2.ClimateHoldSetting) def decode_climate_hold_setting(m: comfort_pb2.ClimateHoldSetting) -> dict[str, Any]: """comfort.cabin.climate_hold_setting — configured climate-hold duration. diff --git a/src/rivian/parallax/proto/comfort.proto b/src/rivian/parallax/proto/comfort.proto index 3f022f2..385ce24 100644 --- a/src/rivian/parallax/proto/comfort.proto +++ b/src/rivian/parallax/proto/comfort.proto @@ -74,6 +74,18 @@ message ClimateHoldSetting { int32 duration = 1; // seconds; empty payload when no hold is set } +// comfort.cabin.set_climate_hold and comfort.cabin.set_pet_mode; the names +// are the app's +message ActionRequest { + Action action = 1; +} + +enum Action { + ACTION_UNSPECIFIED = 0; + ACTION_ON = 1; + ACTION_OFF = 2; +} + // comfort.cabin.climate_hold_status message ClimateHoldStatus { ClimateHoldStatusValue status = 1; diff --git a/src/rivian/parallax/proto/comfort_pb2.py b/src/rivian/parallax/proto/comfort_pb2.py index d46df2b..423b48d 100644 --- a/src/rivian/parallax/proto/comfort_pb2.py +++ b/src/rivian/parallax/proto/comfort_pb2.py @@ -24,37 +24,39 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#rivian/parallax/proto/comfort.proto\x12\x17rivian.parallax.comfort\"0\n\x12HvacSettingsStatus\x12\x1a\n\x12target_temperature\x18\x01 \x01(\x02\"\xa4\x01\n\x0eUserModesState\x12\x12\n\nin_service\x18\x01 \x01(\x08\x12\x15\n\rcar_wash_mode\x18\x02 \x01(\x08\x12\x10\n\x08pet_mode\x18\x03 \x01(\x05\x12\x11\n\tcamp_mode\x18\x04 \x01(\x05\x12\x16\n\x0etransport_mode\x18\x05 \x01(\x05\x12\x14\n\x0c\x63limate_keep\x18\x06 \x01(\x05\x12\x14\n\x0c\x66\x61\x63tory_mode\x18\x07 \x01(\x05\"\x98\x01\n\x1a\x43\x61\x62inPreconditioningStatus\x12>\n\x06status\x18\x01 \x01(\x0e\x32..rivian.parallax.comfort.PreconditioningStatus\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.rivian.parallax.comfort.PreconditioningType\"\xa9\x02\n\x11\x43\x61\x62inTemperatures\x12P\n\x0ctemperatures\x18\x01 \x03(\x0b\x32:.rivian.parallax.comfort.CabinTemperatures.ZoneTemperature\x12!\n\x14\x65xterior_temperature\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x1c\n\x14interior_temperature\x18\x03 \x01(\x02\x12\x1d\n\x10\x64river_set_point\x18\x04 \x01(\x02H\x01\x88\x01\x01\x1a\x34\n\x0fZoneTemperature\x12\x0c\n\x04seat\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x42\x17\n\x15_exterior_temperatureB\x13\n\x11_driver_set_point\"A\n\x17\x43\x61\x62inVentilationSetting\x12&\n\x1e\x61uto_cabin_ventilation_enabled\x18\x01 \x01(\x08\"&\n\x12\x43limateHoldSetting\x12\x10\n\x08\x64uration\x18\x01 \x01(\x05\"\xd7\x02\n\x11\x43limateHoldStatus\x12?\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.comfort.ClimateHoldStatusValue\x12\x46\n\x0c\x61vailability\x18\x02 \x01(\x0e\x32\x30.rivian.parallax.comfort.ClimateHoldAvailability\x12W\n\x15unavailability_reason\x18\x03 \x01(\x0e\x32\x38.rivian.parallax.comfort.ClimateHoldUnavailabilityReason\x12\x44\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x32.rivian.parallax.comfort.ClimateHoldStatus.EndTime\x1a\x1a\n\x07\x45ndTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\"L\n\x12\x44\x65\x66rostDefogStatus\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.rivian.parallax.comfort.DefrostStatus\"\xda\x01\n\rPetModeStatus\x12\x35\n\x06status\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.PetModeState\x12M\n\x12temperature_status\x18\x02 \x01(\x0e\x32\x31.rivian.parallax.comfort.PetModeTemperatureStatus\x12\x43\n\rcabin_climate\x18\x03 \x01(\x0e\x32,.rivian.parallax.comfort.PetModeCabinClimate\"\xa4\x02\n\x16SeatConditioningStatus\x12H\n\x07surface\x18\x01 \x03(\x0b\x32\x37.rivian.parallax.comfort.SeatConditioningStatus.Surface\x1a\xbf\x01\n\x07Surface\x12\x31\n\x02id\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.CabinSurface\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).rivian.parallax.comfort.ConditioningType\x12>\n\x05state\x18\x03 \x01(\x0e\x32*.rivian.parallax.comfort.ConditioningLevelH\x00\x88\x01\x01\x42\x08\n\x06_state*\x85\x03\n\x15PreconditioningStatus\x12&\n\"PRECONDITIONING_STATUS_UNSPECIFIED\x10\x00\x12\x1c\n\x18PRECONDITIONING_INITIATE\x10\x01\x12\x1a\n\x16PRECONDITIONING_ACTIVE\x10\x02\x12\"\n\x1ePRECONDITIONING_ACTIVE_WARNING\x10\x03\x12%\n!PRECONDITIONING_COMPLETE_MAINTAIN\x10\x04\x12-\n)PRECONDITIONING_TIMEOUT_TEMP_NOT_ACHIEVED\x10\x05\x12!\n\x1dPRECONDITIONING_ERROR_SOC_LOW\x10\x06\x12&\n\"PRECONDITIONING_ERROR_SYSTEM_FAULT\x10\x07\x12\x1f\n\x1bPRECONDITIONING_UNAVAILABLE\x10\x08\x12$\n PRECONDITIONING_TIMEOUT_COMPLETE\x10\t*\xe4\x01\n\x13PreconditioningType\x12$\n PRECONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12&\n\"PRECONDITIONING_TYPE_USER_SELECTED\x10\x01\x12*\n&PRECONDITIONING_TYPE_SCREEN_PROTECTION\x10\x02\x12\"\n\x1ePRECONDITIONING_TYPE_SCHEDULED\x10\x03\x12/\n+PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION\x10\x04*\xba\x01\n\x16\x43limateHoldStatusValue\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNSPECIFIED\x10\x00\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNAVAILABLE\x10\x01\x12\x1b\n\x17\x43LIMATE_HOLD_STATUS_OFF\x10\x02\x12\x1a\n\x16\x43LIMATE_HOLD_STATUS_ON\x10\x03\x12\x1d\n\x19\x43LIMATE_HOLD_STATUS_FAULT\x10\x04*\x9d\x01\n\x17\x43limateHoldAvailability\x12)\n%CLIMATE_HOLD_AVAILABILITY_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LIMATE_HOLD_AVAILABLE\x10\x01\x12\x1d\n\x19\x43LIMATE_HOLD_CONTROLLABLE\x10\x02\x12\x1c\n\x18\x43LIMATE_HOLD_UNAVAILABLE\x10\x03*\xc7\x01\n\x1f\x43limateHoldUnavailabilityReason\x12+\n\'CLIMATE_HOLD_UNAVAILABILITY_UNSPECIFIED\x10\x00\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_UNKNOWN\x10\x01\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_LOW_SOC\x10\x02\x12%\n!CLIMATE_HOLD_UNAVAILABILITY_FAULT\x10\x03*\x82\x01\n\rDefrostStatus\x12\x1e\n\x1a\x44\x45\x46ROST_STATUS_UNSPECIFIED\x10\x00\x12\x11\n\rDEFROST_DEFOG\x10\x01\x12\x12\n\x0e\x44\x45\x46ROST_ACTIVE\x10\x02\x12\x19\n\x15\x44\x45\x46ROST_DEFOG_DEFROST\x10\x03\x12\x0f\n\x0b\x44\x45\x46ROST_OFF\x10\x04*~\n\x13PetModeCabinClimate\x12&\n\"PET_MODE_CABIN_CLIMATE_COMFORTABLE\x10\x00\x12\x1f\n\x1bPET_MODE_CABIN_CLIMATE_COLD\x10\x01\x12\x1e\n\x1aPET_MODE_CABIN_CLIMATE_HOT\x10\x02*]\n\x0cPetModeState\x12\x10\n\x0cPET_MODE_OFF\x10\x00\x12\x0f\n\x0bPET_MODE_ON\x10\x01\x12\x15\n\x11PET_MODE_DISABLED\x10\x02\x12\x13\n\x0fPET_MODE_FAULTY\x10\x03*\x9a\x01\n\x18PetModeTemperatureStatus\x12 \n\x1cPET_MODE_TEMPERATURE_DEFAULT\x10\x00\x12\x1d\n\x19PET_MODE_TEMPERATURE_COLD\x10\x01\x12\x1c\n\x18PET_MODE_TEMPERATURE_HOT\x10\x02\x12\x1f\n\x1bPET_MODE_TEMPERATURE_FAULTY\x10\x03*\xce\x02\n\x0c\x43\x61\x62inSurface\x12\x1d\n\x19\x43\x41\x42IN_SURFACE_UNSPECIFIED\x10\x00\x12\x12\n\x0eSTEERING_WHEEL\x10\x01\x12\x0e\n\nREAR_GLASS\x10\x02\x12\x0f\n\x0b\x46RONT_GLASS\x10\x03\x12\x14\n\x10SIDEVIEW_MIRRORS\x10\x04\x12\x13\n\x0fSEAT_ROW_1_LEFT\x10\x05\x12\x15\n\x11SEAT_ROW_1_MIDDLE\x10\x06\x12\x14\n\x10SEAT_ROW_1_RIGHT\x10\x07\x12\x13\n\x0fSEAT_ROW_2_LEFT\x10\x08\x12\x15\n\x11SEAT_ROW_2_MIDDLE\x10\t\x12\x14\n\x10SEAT_ROW_2_RIGHT\x10\n\x12\x13\n\x0fSEAT_ROW_3_LEFT\x10\x0b\x12\x15\n\x11SEAT_ROW_3_MIDDLE\x10\x0c\x12\x14\n\x10SEAT_ROW_3_RIGHT\x10\r\x12\x0e\n\nWIPER_AREA\x10\x0e*c\n\x10\x43onditioningType\x12!\n\x1d\x43ONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43ONDITIONING_HEAT\x10\x01\x12\x15\n\x11\x43ONDITIONING_VENT\x10\x02*\x85\x01\n\x11\x43onditioningLevel\x12\"\n\x1e\x43ONDITIONING_LEVEL_UNSPECIFIED\x10\x00\x12\x18\n\x14\x43ONDITIONING_LEVEL_1\x10\x01\x12\x18\n\x14\x43ONDITIONING_LEVEL_2\x10\x02\x12\x18\n\x14\x43ONDITIONING_LEVEL_3\x10\x03\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#rivian/parallax/proto/comfort.proto\x12\x17rivian.parallax.comfort\"0\n\x12HvacSettingsStatus\x12\x1a\n\x12target_temperature\x18\x01 \x01(\x02\"\xa4\x01\n\x0eUserModesState\x12\x12\n\nin_service\x18\x01 \x01(\x08\x12\x15\n\rcar_wash_mode\x18\x02 \x01(\x08\x12\x10\n\x08pet_mode\x18\x03 \x01(\x05\x12\x11\n\tcamp_mode\x18\x04 \x01(\x05\x12\x16\n\x0etransport_mode\x18\x05 \x01(\x05\x12\x14\n\x0c\x63limate_keep\x18\x06 \x01(\x05\x12\x14\n\x0c\x66\x61\x63tory_mode\x18\x07 \x01(\x05\"\x98\x01\n\x1a\x43\x61\x62inPreconditioningStatus\x12>\n\x06status\x18\x01 \x01(\x0e\x32..rivian.parallax.comfort.PreconditioningStatus\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.rivian.parallax.comfort.PreconditioningType\"\xa9\x02\n\x11\x43\x61\x62inTemperatures\x12P\n\x0ctemperatures\x18\x01 \x03(\x0b\x32:.rivian.parallax.comfort.CabinTemperatures.ZoneTemperature\x12!\n\x14\x65xterior_temperature\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x1c\n\x14interior_temperature\x18\x03 \x01(\x02\x12\x1d\n\x10\x64river_set_point\x18\x04 \x01(\x02H\x01\x88\x01\x01\x1a\x34\n\x0fZoneTemperature\x12\x0c\n\x04seat\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x42\x17\n\x15_exterior_temperatureB\x13\n\x11_driver_set_point\"A\n\x17\x43\x61\x62inVentilationSetting\x12&\n\x1e\x61uto_cabin_ventilation_enabled\x18\x01 \x01(\x08\"&\n\x12\x43limateHoldSetting\x12\x10\n\x08\x64uration\x18\x01 \x01(\x05\"@\n\rActionRequest\x12/\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32\x1f.rivian.parallax.comfort.Action\"\xd7\x02\n\x11\x43limateHoldStatus\x12?\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.comfort.ClimateHoldStatusValue\x12\x46\n\x0c\x61vailability\x18\x02 \x01(\x0e\x32\x30.rivian.parallax.comfort.ClimateHoldAvailability\x12W\n\x15unavailability_reason\x18\x03 \x01(\x0e\x32\x38.rivian.parallax.comfort.ClimateHoldUnavailabilityReason\x12\x44\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x32.rivian.parallax.comfort.ClimateHoldStatus.EndTime\x1a\x1a\n\x07\x45ndTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\"L\n\x12\x44\x65\x66rostDefogStatus\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.rivian.parallax.comfort.DefrostStatus\"\xda\x01\n\rPetModeStatus\x12\x35\n\x06status\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.PetModeState\x12M\n\x12temperature_status\x18\x02 \x01(\x0e\x32\x31.rivian.parallax.comfort.PetModeTemperatureStatus\x12\x43\n\rcabin_climate\x18\x03 \x01(\x0e\x32,.rivian.parallax.comfort.PetModeCabinClimate\"\xa4\x02\n\x16SeatConditioningStatus\x12H\n\x07surface\x18\x01 \x03(\x0b\x32\x37.rivian.parallax.comfort.SeatConditioningStatus.Surface\x1a\xbf\x01\n\x07Surface\x12\x31\n\x02id\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.CabinSurface\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).rivian.parallax.comfort.ConditioningType\x12>\n\x05state\x18\x03 \x01(\x0e\x32*.rivian.parallax.comfort.ConditioningLevelH\x00\x88\x01\x01\x42\x08\n\x06_state*\x85\x03\n\x15PreconditioningStatus\x12&\n\"PRECONDITIONING_STATUS_UNSPECIFIED\x10\x00\x12\x1c\n\x18PRECONDITIONING_INITIATE\x10\x01\x12\x1a\n\x16PRECONDITIONING_ACTIVE\x10\x02\x12\"\n\x1ePRECONDITIONING_ACTIVE_WARNING\x10\x03\x12%\n!PRECONDITIONING_COMPLETE_MAINTAIN\x10\x04\x12-\n)PRECONDITIONING_TIMEOUT_TEMP_NOT_ACHIEVED\x10\x05\x12!\n\x1dPRECONDITIONING_ERROR_SOC_LOW\x10\x06\x12&\n\"PRECONDITIONING_ERROR_SYSTEM_FAULT\x10\x07\x12\x1f\n\x1bPRECONDITIONING_UNAVAILABLE\x10\x08\x12$\n PRECONDITIONING_TIMEOUT_COMPLETE\x10\t*\xe4\x01\n\x13PreconditioningType\x12$\n PRECONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12&\n\"PRECONDITIONING_TYPE_USER_SELECTED\x10\x01\x12*\n&PRECONDITIONING_TYPE_SCREEN_PROTECTION\x10\x02\x12\"\n\x1ePRECONDITIONING_TYPE_SCHEDULED\x10\x03\x12/\n+PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION\x10\x04*?\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\r\n\tACTION_ON\x10\x01\x12\x0e\n\nACTION_OFF\x10\x02*\xba\x01\n\x16\x43limateHoldStatusValue\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNSPECIFIED\x10\x00\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNAVAILABLE\x10\x01\x12\x1b\n\x17\x43LIMATE_HOLD_STATUS_OFF\x10\x02\x12\x1a\n\x16\x43LIMATE_HOLD_STATUS_ON\x10\x03\x12\x1d\n\x19\x43LIMATE_HOLD_STATUS_FAULT\x10\x04*\x9d\x01\n\x17\x43limateHoldAvailability\x12)\n%CLIMATE_HOLD_AVAILABILITY_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LIMATE_HOLD_AVAILABLE\x10\x01\x12\x1d\n\x19\x43LIMATE_HOLD_CONTROLLABLE\x10\x02\x12\x1c\n\x18\x43LIMATE_HOLD_UNAVAILABLE\x10\x03*\xc7\x01\n\x1f\x43limateHoldUnavailabilityReason\x12+\n\'CLIMATE_HOLD_UNAVAILABILITY_UNSPECIFIED\x10\x00\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_UNKNOWN\x10\x01\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_LOW_SOC\x10\x02\x12%\n!CLIMATE_HOLD_UNAVAILABILITY_FAULT\x10\x03*\x82\x01\n\rDefrostStatus\x12\x1e\n\x1a\x44\x45\x46ROST_STATUS_UNSPECIFIED\x10\x00\x12\x11\n\rDEFROST_DEFOG\x10\x01\x12\x12\n\x0e\x44\x45\x46ROST_ACTIVE\x10\x02\x12\x19\n\x15\x44\x45\x46ROST_DEFOG_DEFROST\x10\x03\x12\x0f\n\x0b\x44\x45\x46ROST_OFF\x10\x04*~\n\x13PetModeCabinClimate\x12&\n\"PET_MODE_CABIN_CLIMATE_COMFORTABLE\x10\x00\x12\x1f\n\x1bPET_MODE_CABIN_CLIMATE_COLD\x10\x01\x12\x1e\n\x1aPET_MODE_CABIN_CLIMATE_HOT\x10\x02*]\n\x0cPetModeState\x12\x10\n\x0cPET_MODE_OFF\x10\x00\x12\x0f\n\x0bPET_MODE_ON\x10\x01\x12\x15\n\x11PET_MODE_DISABLED\x10\x02\x12\x13\n\x0fPET_MODE_FAULTY\x10\x03*\x9a\x01\n\x18PetModeTemperatureStatus\x12 \n\x1cPET_MODE_TEMPERATURE_DEFAULT\x10\x00\x12\x1d\n\x19PET_MODE_TEMPERATURE_COLD\x10\x01\x12\x1c\n\x18PET_MODE_TEMPERATURE_HOT\x10\x02\x12\x1f\n\x1bPET_MODE_TEMPERATURE_FAULTY\x10\x03*\xce\x02\n\x0c\x43\x61\x62inSurface\x12\x1d\n\x19\x43\x41\x42IN_SURFACE_UNSPECIFIED\x10\x00\x12\x12\n\x0eSTEERING_WHEEL\x10\x01\x12\x0e\n\nREAR_GLASS\x10\x02\x12\x0f\n\x0b\x46RONT_GLASS\x10\x03\x12\x14\n\x10SIDEVIEW_MIRRORS\x10\x04\x12\x13\n\x0fSEAT_ROW_1_LEFT\x10\x05\x12\x15\n\x11SEAT_ROW_1_MIDDLE\x10\x06\x12\x14\n\x10SEAT_ROW_1_RIGHT\x10\x07\x12\x13\n\x0fSEAT_ROW_2_LEFT\x10\x08\x12\x15\n\x11SEAT_ROW_2_MIDDLE\x10\t\x12\x14\n\x10SEAT_ROW_2_RIGHT\x10\n\x12\x13\n\x0fSEAT_ROW_3_LEFT\x10\x0b\x12\x15\n\x11SEAT_ROW_3_MIDDLE\x10\x0c\x12\x14\n\x10SEAT_ROW_3_RIGHT\x10\r\x12\x0e\n\nWIPER_AREA\x10\x0e*c\n\x10\x43onditioningType\x12!\n\x1d\x43ONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43ONDITIONING_HEAT\x10\x01\x12\x15\n\x11\x43ONDITIONING_VENT\x10\x02*\x85\x01\n\x11\x43onditioningLevel\x12\"\n\x1e\x43ONDITIONING_LEVEL_UNSPECIFIED\x10\x00\x12\x18\n\x14\x43ONDITIONING_LEVEL_1\x10\x01\x12\x18\n\x14\x43ONDITIONING_LEVEL_2\x10\x02\x12\x18\n\x14\x43ONDITIONING_LEVEL_3\x10\x03\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rivian.parallax.proto.comfort_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None - _globals['_PRECONDITIONINGSTATUS']._serialized_start=1784 - _globals['_PRECONDITIONINGSTATUS']._serialized_end=2173 - _globals['_PRECONDITIONINGTYPE']._serialized_start=2176 - _globals['_PRECONDITIONINGTYPE']._serialized_end=2404 - _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_start=2407 - _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_end=2593 - _globals['_CLIMATEHOLDAVAILABILITY']._serialized_start=2596 - _globals['_CLIMATEHOLDAVAILABILITY']._serialized_end=2753 - _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_start=2756 - _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_end=2955 - _globals['_DEFROSTSTATUS']._serialized_start=2958 - _globals['_DEFROSTSTATUS']._serialized_end=3088 - _globals['_PETMODECABINCLIMATE']._serialized_start=3090 - _globals['_PETMODECABINCLIMATE']._serialized_end=3216 - _globals['_PETMODESTATE']._serialized_start=3218 - _globals['_PETMODESTATE']._serialized_end=3311 - _globals['_PETMODETEMPERATURESTATUS']._serialized_start=3314 - _globals['_PETMODETEMPERATURESTATUS']._serialized_end=3468 - _globals['_CABINSURFACE']._serialized_start=3471 - _globals['_CABINSURFACE']._serialized_end=3805 - _globals['_CONDITIONINGTYPE']._serialized_start=3807 - _globals['_CONDITIONINGTYPE']._serialized_end=3906 - _globals['_CONDITIONINGLEVEL']._serialized_start=3909 - _globals['_CONDITIONINGLEVEL']._serialized_end=4042 + _globals['_PRECONDITIONINGSTATUS']._serialized_start=1850 + _globals['_PRECONDITIONINGSTATUS']._serialized_end=2239 + _globals['_PRECONDITIONINGTYPE']._serialized_start=2242 + _globals['_PRECONDITIONINGTYPE']._serialized_end=2470 + _globals['_ACTION']._serialized_start=2472 + _globals['_ACTION']._serialized_end=2535 + _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_start=2538 + _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_end=2724 + _globals['_CLIMATEHOLDAVAILABILITY']._serialized_start=2727 + _globals['_CLIMATEHOLDAVAILABILITY']._serialized_end=2884 + _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_start=2887 + _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_end=3086 + _globals['_DEFROSTSTATUS']._serialized_start=3089 + _globals['_DEFROSTSTATUS']._serialized_end=3219 + _globals['_PETMODECABINCLIMATE']._serialized_start=3221 + _globals['_PETMODECABINCLIMATE']._serialized_end=3347 + _globals['_PETMODESTATE']._serialized_start=3349 + _globals['_PETMODESTATE']._serialized_end=3442 + _globals['_PETMODETEMPERATURESTATUS']._serialized_start=3445 + _globals['_PETMODETEMPERATURESTATUS']._serialized_end=3599 + _globals['_CABINSURFACE']._serialized_start=3602 + _globals['_CABINSURFACE']._serialized_end=3936 + _globals['_CONDITIONINGTYPE']._serialized_start=3938 + _globals['_CONDITIONINGTYPE']._serialized_end=4037 + _globals['_CONDITIONINGLEVEL']._serialized_start=4040 + _globals['_CONDITIONINGLEVEL']._serialized_end=4173 _globals['_HVACSETTINGSSTATUS']._serialized_start=64 _globals['_HVACSETTINGSSTATUS']._serialized_end=112 _globals['_USERMODESSTATE']._serialized_start=115 @@ -69,16 +71,18 @@ _globals['_CABINVENTILATIONSETTING']._serialized_end=801 _globals['_CLIMATEHOLDSETTING']._serialized_start=803 _globals['_CLIMATEHOLDSETTING']._serialized_end=841 - _globals['_CLIMATEHOLDSTATUS']._serialized_start=844 - _globals['_CLIMATEHOLDSTATUS']._serialized_end=1187 - _globals['_CLIMATEHOLDSTATUS_ENDTIME']._serialized_start=1161 - _globals['_CLIMATEHOLDSTATUS_ENDTIME']._serialized_end=1187 - _globals['_DEFROSTDEFOGSTATUS']._serialized_start=1189 - _globals['_DEFROSTDEFOGSTATUS']._serialized_end=1265 - _globals['_PETMODESTATUS']._serialized_start=1268 - _globals['_PETMODESTATUS']._serialized_end=1486 - _globals['_SEATCONDITIONINGSTATUS']._serialized_start=1489 - _globals['_SEATCONDITIONINGSTATUS']._serialized_end=1781 - _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_start=1590 - _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_end=1781 + _globals['_ACTIONREQUEST']._serialized_start=843 + _globals['_ACTIONREQUEST']._serialized_end=907 + _globals['_CLIMATEHOLDSTATUS']._serialized_start=910 + _globals['_CLIMATEHOLDSTATUS']._serialized_end=1253 + _globals['_CLIMATEHOLDSTATUS_ENDTIME']._serialized_start=1227 + _globals['_CLIMATEHOLDSTATUS_ENDTIME']._serialized_end=1253 + _globals['_DEFROSTDEFOGSTATUS']._serialized_start=1255 + _globals['_DEFROSTDEFOGSTATUS']._serialized_end=1331 + _globals['_PETMODESTATUS']._serialized_start=1334 + _globals['_PETMODESTATUS']._serialized_end=1552 + _globals['_SEATCONDITIONINGSTATUS']._serialized_start=1555 + _globals['_SEATCONDITIONINGSTATUS']._serialized_end=1847 + _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_start=1656 + _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_end=1847 # @@protoc_insertion_point(module_scope) diff --git a/src/rivian/parallax/proto/comfort_pb2.pyi b/src/rivian/parallax/proto/comfort_pb2.pyi index 6e14bc4..2d24d8d 100644 --- a/src/rivian/parallax/proto/comfort_pb2.pyi +++ b/src/rivian/parallax/proto/comfort_pb2.pyi @@ -28,6 +28,12 @@ class PreconditioningType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): PRECONDITIONING_TYPE_SCHEDULED: _ClassVar[PreconditioningType] PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION: _ClassVar[PreconditioningType] +class Action(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + ACTION_UNSPECIFIED: _ClassVar[Action] + ACTION_ON: _ClassVar[Action] + ACTION_OFF: _ClassVar[Action] + class ClimateHoldStatusValue(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): __slots__ = () CLIMATE_HOLD_STATUS_UNSPECIFIED: _ClassVar[ClimateHoldStatusValue] @@ -123,6 +129,9 @@ PRECONDITIONING_TYPE_USER_SELECTED: PreconditioningType PRECONDITIONING_TYPE_SCREEN_PROTECTION: PreconditioningType PRECONDITIONING_TYPE_SCHEDULED: PreconditioningType PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION: PreconditioningType +ACTION_UNSPECIFIED: Action +ACTION_ON: Action +ACTION_OFF: Action CLIMATE_HOLD_STATUS_UNSPECIFIED: ClimateHoldStatusValue CLIMATE_HOLD_STATUS_UNAVAILABLE: ClimateHoldStatusValue CLIMATE_HOLD_STATUS_OFF: ClimateHoldStatusValue @@ -238,6 +247,12 @@ class ClimateHoldSetting(_message.Message): duration: int def __init__(self, duration: _Optional[int] = ...) -> None: ... +class ActionRequest(_message.Message): + __slots__ = ("action",) + ACTION_FIELD_NUMBER: _ClassVar[int] + action: Action + def __init__(self, action: _Optional[_Union[Action, str]] = ...) -> None: ... + class ClimateHoldStatus(_message.Message): __slots__ = ("status", "availability", "unavailability_reason", "end_time") class EndTime(_message.Message): diff --git a/tests/parallax/test_comfort.py b/tests/parallax/test_comfort.py index aec1f47..282352f 100644 --- a/tests/parallax/test_comfort.py +++ b/tests/parallax/test_comfort.py @@ -4,7 +4,12 @@ import pytest -from rivian.parallax import CLIMATE_HOLD_SETTING_RVM, encode_climate_hold_setting +from rivian.parallax import ( + CLIMATE_HOLD_SETTING_RVM, + encode_climate_hold, + encode_climate_hold_setting, + encode_pet_mode, +) from rivian.parallax.proto import comfort_pb2 as comfort from .helpers import decode @@ -86,6 +91,12 @@ def test_climate_hold_setting() -> None: assert decode(CLIMATE_HOLD_SETTING_RVM, setting) == {"climateHoldDuration": 7200} +def test_climate_hold_and_pet_mode() -> None: + """On and off encode like the Rivian app's.""" + assert encode_climate_hold(True) == encode_pet_mode(True) == b"\x08\x01" + assert encode_climate_hold(False) == encode_pet_mode(False) == b"\x08\x02" + + def test_climate_hold_status() -> None: """The end time is read from its {seconds} wrapper.""" status = comfort.ClimateHoldStatus From 5fc9110aef36c452aef103735ebe580230614df0 Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Sun, 8 Nov 2026 01:37:57 +0000 Subject: [PATCH 7/8] Add Parallax equivalents of vehicle commands 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. --- src/rivian/parallax/__init__.py | 8 + src/rivian/parallax/proto/body.proto | 5 + src/rivian/parallax/proto/body_pb2.py | 104 ++++----- src/rivian/parallax/proto/body_pb2.pyi | 6 + src/rivian/parallax/proto/charging.proto | 5 + src/rivian/parallax/proto/charging_pb2.py | 40 ++-- src/rivian/parallax/proto/charging_pb2.pyi | 6 + src/rivian/parallax/proto/comfort.proto | 24 +++ src/rivian/parallax/proto/comfort_pb2.py | 74 ++++--- src/rivian/parallax/proto/comfort_pb2.pyi | 33 +++ src/rivian/parallax/vehicle_command.py | 236 +++++++++++++++++++++ tests/parallax/test_vehicle_command.py | 127 +++++++++++ 12 files changed, 565 insertions(+), 103 deletions(-) create mode 100644 src/rivian/parallax/vehicle_command.py create mode 100644 tests/parallax/test_vehicle_command.py diff --git a/src/rivian/parallax/__init__.py b/src/rivian/parallax/__init__.py index 1d28390..1e2f53d 100644 --- a/src/rivian/parallax/__init__.py +++ b/src/rivian/parallax/__init__.py @@ -24,6 +24,11 @@ encode_climate_hold(on), encode_pet_mode(on) -> bytes Payloads for the signed SET_CLIMATE_HOLD_RVM and SET_PET_MODE_RVM commands. + vehicle_command_feature(command) -> str | None + The supported feature that, when AVAILABLE, sends a `VehicleCommand` + over Parallax. + encode_vehicle_command(command, params=None) -> (rvm, payload) + The command's Parallax equivalent, for `send_parallax_command`. Layout: core.py - registry, payload parsing and shared helpers @@ -82,6 +87,7 @@ START_LIVE_STREAMING_RVM, encode_live_streaming, ) +from .vehicle_command import encode_vehicle_command, vehicle_command_feature PARALLAX_RVMS: list[str] = list(RVMDecoder.decoders) @@ -121,5 +127,7 @@ "encode_lock", "encode_pet_mode", "encode_unlock", + "encode_vehicle_command", "encode_vehicle_operation", + "vehicle_command_feature", ] diff --git a/src/rivian/parallax/proto/body.proto b/src/rivian/parallax/proto/body.proto index f89a768..5671295 100644 --- a/src/rivian/parallax/proto/body.proto +++ b/src/rivian/parallax/proto/body.proto @@ -48,6 +48,11 @@ enum ClosureId { GROUP_WINDOWS = 10000; // all windows together } +// body.closures.open and body.closures.close +message ClosuresRequest { + repeated ClosureId closures = 1; +} + enum ClosureState { CLOSURE_STATE_UNSPECIFIED = 0; CLOSURE_STATE_OPEN = 1; diff --git a/src/rivian/parallax/proto/body_pb2.py b/src/rivian/parallax/proto/body_pb2.py index 7e20105..6b9fd5d 100644 --- a/src/rivian/parallax/proto/body_pb2.py +++ b/src/rivian/parallax/proto/body_pb2.py @@ -24,65 +24,67 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n rivian/parallax/proto/body.proto\x12\x14rivian.parallax.body\"\x89\x06\n\rClosuresState\x12<\n\x07\x63losure\x18\x01 \x03(\x0b\x32+.rivian.parallax.body.ClosuresState.Closure\x1a\xb9\x05\n\x07\x43losure\x12+\n\x02id\x18\x01 \x01(\x0e\x32\x1f.rivian.parallax.body.ClosureId\x12\x36\n\x05state\x18\x02 \x01(\x0e\x32\".rivian.parallax.body.ClosureStateH\x01\x88\x01\x01\x12\x1d\n\x15open_position_percent\x18\x03 \x01(\x05\x12\x31\n\x05\x66\x61ult\x18\x04 \x01(\x0e\x32\".rivian.parallax.body.ClosureFault\x12\x46\n\x13windows_next_action\x18\x05 \x01(\x0e\x32\'.rivian.parallax.body.WindowsNextActionH\x00\x12\x42\n\x11\x66runk_next_action\x18\x06 \x01(\x0e\x32%.rivian.parallax.body.FrunkNextActionH\x00\x12H\n\x14liftgate_next_action\x18\x07 \x01(\x0e\x32(.rivian.parallax.body.LiftgateNextActionH\x00\x12G\n\x14side_bin_next_action\x18\x08 \x01(\x0e\x32\'.rivian.parallax.body.SideBinNextActionH\x00\x12H\n\x14tailgate_next_action\x18\t \x01(\x0e\x32(.rivian.parallax.body.TailgateNextActionH\x00\x12V\n\x1c\x63harge_port_door_next_action\x18\n \x01(\x0e\x32..rivian.parallax.body.ChargePortDoorNextActionH\x00\x12\x1d\n\x13tonneau_next_action\x18\x0b \x01(\x05H\x00\x42\r\n\x0bnext_actionB\x08\n\x06_state\"\xe3\x01\n\nLocksState\x12\x33\n\x04lock\x18\x01 \x03(\x0b\x32%.rivian.parallax.body.LocksState.Lock\x1a\x9f\x01\n\x04Lock\x12(\n\x02id\x18\x01 \x01(\x0e\x32\x1c.rivian.parallax.body.LockId\x12\x33\n\x05state\x18\x02 \x01(\x0e\x32\x1f.rivian.parallax.body.LockStateH\x00\x88\x01\x01\x12.\n\x05\x66\x61ult\x18\x03 \x01(\x0e\x32\x1f.rivian.parallax.body.LockFaultB\x08\n\x06_state\"\xd1\x01\n\x0cWindowsState\x12\x39\n\x06window\x18\x01 \x03(\x0b\x32).rivian.parallax.body.WindowsState.Window\x1a\x85\x01\n\x06Window\x12\x36\n\x08instance\x18\x01 \x01(\x0e\x32$.rivian.parallax.body.WindowInstance\x12\x43\n\x12\x63\x61libration_status\x18\x02 \x01(\x0e\x32\'.rivian.parallax.body.CalibrationStatus\"\x9b\x01\n\x0cTrailerState\x12<\n\x08presence\x18\x01 \x01(\x0e\x32%.rivian.parallax.body.TrailerPresenceH\x00\x88\x01\x01\x12@\n\x11rear_hitch_status\x18\x02 \x01(\x0e\x32%.rivian.parallax.body.RearHitchStatusB\x0b\n\t_presence\"G\n\x0fWiperFluidLevel\x12\x34\n\x05state\x18\x02 \x01(\x0e\x32%.rivian.parallax.body.WiperFluidState\"C\n\rUnlockCommand\x12\r\n\x03\x61ll\x18\x01 \x01(\x08H\x00\x12\x19\n\x0fuser_preference\x18\x02 \x01(\x08H\x00\x42\x08\n\x06target\"\r\n\x0bLockCommand*\xe8\x02\n\tClosureId\x12\x1a\n\x16\x43LOSURE_ID_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x44OOR_FRONT_LEFT\x10\x01\x12\x14\n\x10\x44OOR_FRONT_RIGHT\x10\x02\x12\x12\n\x0e\x44OOR_REAR_LEFT\x10\x03\x12\x13\n\x0f\x44OOR_REAR_RIGHT\x10\x04\x12\t\n\x05\x46RUNK\x10\x05\x12\x0c\n\x08TAILGATE\x10\x06\x12\x0c\n\x08LIFTGATE\x10\x07\x12\x11\n\rSIDE_BIN_LEFT\x10\x08\x12\x12\n\x0eSIDE_BIN_RIGHT\x10\t\x12\x0f\n\x0b\x43HARGE_PORT\x10\n\x12\x0b\n\x07TONNEAU\x10\x0b\x12\x15\n\x11WINDOW_FRONT_LEFT\x10\x0c\x12\x16\n\x12WINDOW_FRONT_RIGHT\x10\r\x12\x14\n\x10WINDOW_REAR_LEFT\x10\x0e\x12\x15\n\x11WINDOW_REAR_RIGHT\x10\x0f\x12\x0f\n\x0bWINDOW_REAR\x10\x10\x12\x12\n\rGROUP_WINDOWS\x10\x90N*\xad\x01\n\x0c\x43losureState\x12\x1d\n\x19\x43LOSURE_STATE_UNSPECIFIED\x10\x00\x12\x16\n\x12\x43LOSURE_STATE_OPEN\x10\x01\x12\x18\n\x14\x43LOSURE_STATE_CLOSED\x10\x02\x12\x16\n\x12\x43LOSURE_STATE_AJAR\x10\x03\x12\x19\n\x15\x43LOSURE_STATE_OPENING\x10\x04\x12\x19\n\x15\x43LOSURE_STATE_CLOSING\x10\x05*\xf3\x02\n\x06LockId\x12\x17\n\x13LOCK_ID_UNSPECIFIED\x10\x00\x12\x18\n\x14LOCK_DOOR_FRONT_LEFT\x10\x01\x12\x19\n\x15LOCK_DOOR_FRONT_RIGHT\x10\x02\x12\x17\n\x13LOCK_DOOR_REAR_LEFT\x10\x03\x12\x18\n\x14LOCK_DOOR_REAR_RIGHT\x10\x04\x12\x0e\n\nLOCK_FRUNK\x10\x05\x12\x11\n\rLOCK_TAILGATE\x10\x06\x12\x11\n\rLOCK_LIFTGATE\x10\x07\x12\x16\n\x12LOCK_SIDE_BIN_LEFT\x10\x08\x12\x17\n\x13LOCK_SIDE_BIN_RIGHT\x10\t\x12\x14\n\x10LOCK_CHARGE_PORT\x10\n\x12\x17\n\x13LOCK_TRUNK_SECURITY\x10\x0b\x12\x17\n\x13LOCK_CENTER_CONSOLE\x10\x0c\x12\x12\n\x0eLOCK_GLOVE_BOX\x10\r\x12\x13\n\x0fLOCK_GEAR_GUARD\x10\x0e\x12\x10\n\x0cLOCK_TONNEAU\x10\x0f*z\n\tLockState\x12\x1a\n\x16LOCK_STATE_UNSPECIFIED\x10\x00\x12\x15\n\x11LOCK_STATE_LOCKED\x10\x01\x12\x17\n\x13LOCK_STATE_UNLOCKED\x10\x02\x12!\n\x1dLOCK_STATE_PARTIALLY_UNLOCKED\x10\x03*?\n\tLockFault\x12\x1a\n\x16LOCK_FAULT_UNSPECIFIED\x10\x00\x12\x16\n\x12LOCK_FAULT_FAULTED\x10\x01*\xcb\x01\n\x0eWindowInstance\x12\x1f\n\x1bWINDOW_INSTANCE_UNSPECIFIED\x10\x00\x12\x1e\n\x1aWINDOW_INSTANCE_FRONT_LEFT\x10\x01\x12\x1f\n\x1bWINDOW_INSTANCE_FRONT_RIGHT\x10\x02\x12\x1d\n\x19WINDOW_INSTANCE_REAR_LEFT\x10\x03\x12\x1e\n\x1aWINDOW_INSTANCE_REAR_RIGHT\x10\x04\x12\x18\n\x14WINDOW_INSTANCE_REAR\x10\x05*\x81\x01\n\x11\x43\x61librationStatus\x12\"\n\x1e\x43\x41LIBRATION_STATUS_UNSPECIFIED\x10\x00\x12!\n\x1d\x43\x41LIBRATION_STATUS_CALIBRATED\x10\x01\x12%\n!CALIBRATION_STATUS_NOT_CALIBRATED\x10\x02*\xd8\x01\n\x0fRearHitchStatus\x12!\n\x1dREAR_HITCH_STATUS_UNSPECIFIED\x10\x00\x12!\n\x1dREAR_HITCH_STATUS_NOT_PRESENT\x10\x01\x12\x1f\n\x1bREAR_HITCH_STATUS_ACCESSORY\x10\x02\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER1\x10\x03\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER2\x10\x04\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER3\x10\x05*\xaa\x01\n\x0c\x43losureFault\x12\x1d\n\x19\x43LOSURE_FAULT_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LOSURE_FAULT_NO_FAULT\x10\x01\x12\x19\n\x15\x43LOSURE_FAULT_GENERAL\x10\x02\x12&\n\"CLOSURE_FAULT_NO_POWERED_OPERATION\x10\x03\x12\x1c\n\x18\x43LOSURE_FAULT_OBSTRUCTED\x10\x04*\x97\x01\n\x0fTrailerPresence\x12 \n\x1cTRAILER_PRESENCE_UNSPECIFIED\x10\x00\x12\x17\n\x13TRAILER_NOT_PRESENT\x10\x01\x12\x13\n\x0fTRAILER_PRESENT\x10\x02\x12\x1f\n\x1bTRAILER_PRESENT_WITH_BRAKES\x10\x03\x12\x13\n\x0fTRAILER_INVALID\x10\x04*\x9f\x04\n\x18\x43hargePortDoorNextAction\x12\x18\n\x14\x43HARGE_PORT_DOOR_SNA\x10\x00\x12!\n\x1d\x43HARGE_PORT_DOOR_OPEN_ALLOWED\x10\x01\x12\'\n#CHARGE_PORT_DOOR_OPEN_NOT_AVAILABLE\x10\x02\x12-\n)CHARGE_PORT_DOOR_OPEN_NOT_ALLOWED_FAULTED\x10\x03\x12\x1c\n\x18\x43HARGE_PORT_DOOR_OPENING\x10\x04\x12\"\n\x1e\x43HARGE_PORT_DOOR_CLOSE_ALLOWED\x10\x05\x12;\n7CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_OPENING_CLOSE_ALLOWED\x10\x06\x12:\n6CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_OPENING_OPEN_ALLOWED\x10\x07\x12;\n7CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_CLOSING_CLOSE_ALLOWED\x10\x08\x12(\n$CHARGE_PORT_DOOR_CLOSE_NOT_AVAILABLE\x10\t\x12.\n*CHARGE_PORT_DOOR_CLOSE_NOT_ALLOWED_FAULTED\x10\n\x12\x1c\n\x18\x43HARGE_PORT_DOOR_CLOSING\x10\x0b*\xb0\x03\n\x0f\x46runkNextAction\x12\r\n\tFRUNK_SNA\x10\x00\x12\x16\n\x12\x46RUNK_OPEN_ALLOWED\x10\x01\x12\x17\n\x13\x46RUNK_CLOSE_ALLOWED\x10\x02\x12\x11\n\rFRUNK_OPENING\x10\x03\x12\x11\n\rFRUNK_CLOSING\x10\x04\x12\x1c\n\x18\x46RUNK_OPEN_NOT_AVAILABLE\x10\x05\x12\x1d\n\x19\x46RUNK_CLOSE_NOT_AVAILABLE\x10\x06\x12\"\n\x1e\x46RUNK_OPEN_NOT_ALLOWED_FAULTED\x10\x07\x12#\n\x1f\x46RUNK_CLOSE_NOT_ALLOWED_FAULTED\x10\x08\x12)\n%FRUNK_OPEN_ALLOWED_NO_POWER_OPERATION\x10\t\x12.\n*FRUNK_CLOSE_NOT_ALLOWED_NO_POWER_OPERATION\x10\n\x12*\n&FRUNK_OBSTRUCTED_OPENING_CLOSE_ALLOWED\x10\x0b\x12*\n&FRUNK_OBSTRUCTED_CLOSING_CLOSE_ALLOWED\x10\x0c*\xa7\x06\n\x12LiftgateNextAction\x12\x10\n\x0cLIFTGATE_SNA\x10\x00\x12\x19\n\x15LIFTGATE_OPEN_ALLOWED\x10\x01\x12\x1a\n\x16LIFTGATE_CLOSE_ALLOWED\x10\x02\x12\x14\n\x10LIFTGATE_OPENING\x10\x03\x12\x14\n\x10LIFTGATE_CLOSING\x10\x04\x12\x1f\n\x1bLIFTGATE_OPEN_NOT_AVAILABLE\x10\x05\x12 \n\x1cLIFTGATE_CLOSE_NOT_AVAILABLE\x10\x06\x12%\n!LIFTGATE_OPEN_NOT_ALLOWED_FAULTED\x10\x07\x12&\n\"LIFTGATE_CLOSE_NOT_ALLOWED_FAULTED\x10\x08\x12,\n(LIFTGATE_OPEN_ALLOWED_NO_POWER_OPERATION\x10\t\x12\x31\n-LIFTGATE_CLOSE_NOT_ALLOWED_NO_POWER_OPERATION\x10\n\x12-\n)LIFTGATE_OBSTRUCTED_OPENING_CLOSE_ALLOWED\x10\x0b\x12-\n)LIFTGATE_OBSTRUCTED_CLOSING_CLOSE_ALLOWED\x10\x0c\x12.\n*LIFTGATE_LOWER_GATE_OPEN_CLOSE_NOT_ALLOWED\x10\r\x12&\n\"LIFTGATE_OPENING_PAUSE_NOT_ALLOWED\x10\x0e\x12&\n\"LIFTGATE_CLOSING_PAUSE_NOT_ALLOWED\x10\x0f\x12+\n\'LIFTGATE_OPEN_ALLOWED_OBSTACLE_DETECTED\x10\x10\x12*\n&LIFTGATE_OPEN_ALLOWED_TRAILER_DETECTED\x10\x11\x12,\n(LIFTGATE_CLOSE_ALLOWED_OBSTACLE_DETECTED\x10\x12\x12+\n\'LIFTGATE_CLOSE_ALLOWED_TRAILER_DETECTED\x10\x13\x12\x17\n\x13LIFTGATE_PROCESSING\x10\x14*\xb2\x02\n\x11SideBinNextAction\x12\x10\n\x0cSIDE_BIN_SNA\x10\x00\x12\x19\n\x15SIDE_BIN_OPEN_ALLOWED\x10\x01\x12\x14\n\x10SIDE_BIN_OPENING\x10\x02\x12\x1f\n\x1bSIDE_BIN_OPEN_NOT_AVAILABLE\x10\x03\x12%\n!SIDE_BIN_OPEN_NOT_ALLOWED_FAULTED\x10\x04\x12\x32\n.SIDE_BIN_STUCK_AJAR_WHILE_OPENING_OPEN_ALLOWED\x10\x05\x12-\n)SIDE_BIN_OPEN_ALREADY_NO_ACTION_AVAILABLE\x10\x06\x12/\n+SIDE_BIN_OPEN_ALLOWED_CONFIRM_VEHICLE_ANGLE\x10\x07*\x8c\x03\n\x12TailgateNextAction\x12\x10\n\x0cTAILGATE_SNA\x10\x00\x12\x19\n\x15TAILGATE_OPEN_ALLOWED\x10\x01\x12\x14\n\x10TAILGATE_OPENING\x10\x02\x12\x1f\n\x1bTAILGATE_OPEN_NOT_AVAILABLE\x10\x03\x12%\n!TAILGATE_OPEN_NOT_ALLOWED_FAULTED\x10\x04\x12\x32\n.TAILGATE_STUCK_AJAR_WHILE_OPENING_OPEN_ALLOWED\x10\x05\x12-\n)TAILGATE_OPEN_ALREADY_NO_ACTION_AVAILABLE\x10\x06\x12/\n+TAILGATE_OPEN_ALLOWED_CONFIRM_VEHICLE_ANGLE\x10\x07\x12+\n\'TAILGATE_OPEN_ALLOWED_OBSTACLE_DETECTED\x10\x08\x12*\n&TAILGATE_OPEN_ALLOWED_TRAILER_DETECTED\x10\t*\xb0\x03\n\x11WindowsNextAction\x12\x0f\n\x0bWINDOWS_SNA\x10\x00\x12\x18\n\x14WINDOWS_OPEN_ALLOWED\x10\x01\x12\x19\n\x15WINDOWS_CLOSE_ALLOWED\x10\x02\x12\x13\n\x0fWINDOWS_OPENING\x10\x03\x12\x13\n\x0fWINDOWS_CLOSING\x10\x04\x12\x12\n\x0eWINDOWS_MOVING\x10\x05\x12\x1e\n\x1aWINDOWS_OPEN_NOT_AVAILABLE\x10\x06\x12\x1f\n\x1bWINDOWS_CLOSE_NOT_AVAILABLE\x10\x07\x12$\n WINDOWS_OPEN_NOT_ALLOWED_FAULTED\x10\x08\x12%\n!WINDOWS_CLOSE_NOT_ALLOWED_FAULTED\x10\t\x12\x32\n.WINDOWS_OBSTRUCTED_WHILE_CLOSING_CLOSE_ALLOWED\x10\n\x12*\n&WINDOWS_CLOSE_NOT_ALLOWED_UNCALIBRATED\x10\x0b\x12)\n%WINDOWS_OPEN_NOT_ALLOWED_UNCALIBRATED\x10\x0c*\x8a\x01\n\x0fWiperFluidState\x12!\n\x1dWIPER_FLUID_STATE_UNSPECIFIED\x10\x00\x12\x1c\n\x18WIPER_FLUID_STATE_NORMAL\x10\x01\x12\x19\n\x15WIPER_FLUID_STATE_LOW\x10\x02\x12\x1b\n\x17WIPER_FLUID_STATE_EMPTY\x10\x03\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n rivian/parallax/proto/body.proto\x12\x14rivian.parallax.body\"\x89\x06\n\rClosuresState\x12<\n\x07\x63losure\x18\x01 \x03(\x0b\x32+.rivian.parallax.body.ClosuresState.Closure\x1a\xb9\x05\n\x07\x43losure\x12+\n\x02id\x18\x01 \x01(\x0e\x32\x1f.rivian.parallax.body.ClosureId\x12\x36\n\x05state\x18\x02 \x01(\x0e\x32\".rivian.parallax.body.ClosureStateH\x01\x88\x01\x01\x12\x1d\n\x15open_position_percent\x18\x03 \x01(\x05\x12\x31\n\x05\x66\x61ult\x18\x04 \x01(\x0e\x32\".rivian.parallax.body.ClosureFault\x12\x46\n\x13windows_next_action\x18\x05 \x01(\x0e\x32\'.rivian.parallax.body.WindowsNextActionH\x00\x12\x42\n\x11\x66runk_next_action\x18\x06 \x01(\x0e\x32%.rivian.parallax.body.FrunkNextActionH\x00\x12H\n\x14liftgate_next_action\x18\x07 \x01(\x0e\x32(.rivian.parallax.body.LiftgateNextActionH\x00\x12G\n\x14side_bin_next_action\x18\x08 \x01(\x0e\x32\'.rivian.parallax.body.SideBinNextActionH\x00\x12H\n\x14tailgate_next_action\x18\t \x01(\x0e\x32(.rivian.parallax.body.TailgateNextActionH\x00\x12V\n\x1c\x63harge_port_door_next_action\x18\n \x01(\x0e\x32..rivian.parallax.body.ChargePortDoorNextActionH\x00\x12\x1d\n\x13tonneau_next_action\x18\x0b \x01(\x05H\x00\x42\r\n\x0bnext_actionB\x08\n\x06_state\"D\n\x0f\x43losuresRequest\x12\x31\n\x08\x63losures\x18\x01 \x03(\x0e\x32\x1f.rivian.parallax.body.ClosureId\"\xe3\x01\n\nLocksState\x12\x33\n\x04lock\x18\x01 \x03(\x0b\x32%.rivian.parallax.body.LocksState.Lock\x1a\x9f\x01\n\x04Lock\x12(\n\x02id\x18\x01 \x01(\x0e\x32\x1c.rivian.parallax.body.LockId\x12\x33\n\x05state\x18\x02 \x01(\x0e\x32\x1f.rivian.parallax.body.LockStateH\x00\x88\x01\x01\x12.\n\x05\x66\x61ult\x18\x03 \x01(\x0e\x32\x1f.rivian.parallax.body.LockFaultB\x08\n\x06_state\"\xd1\x01\n\x0cWindowsState\x12\x39\n\x06window\x18\x01 \x03(\x0b\x32).rivian.parallax.body.WindowsState.Window\x1a\x85\x01\n\x06Window\x12\x36\n\x08instance\x18\x01 \x01(\x0e\x32$.rivian.parallax.body.WindowInstance\x12\x43\n\x12\x63\x61libration_status\x18\x02 \x01(\x0e\x32\'.rivian.parallax.body.CalibrationStatus\"\x9b\x01\n\x0cTrailerState\x12<\n\x08presence\x18\x01 \x01(\x0e\x32%.rivian.parallax.body.TrailerPresenceH\x00\x88\x01\x01\x12@\n\x11rear_hitch_status\x18\x02 \x01(\x0e\x32%.rivian.parallax.body.RearHitchStatusB\x0b\n\t_presence\"G\n\x0fWiperFluidLevel\x12\x34\n\x05state\x18\x02 \x01(\x0e\x32%.rivian.parallax.body.WiperFluidState\"C\n\rUnlockCommand\x12\r\n\x03\x61ll\x18\x01 \x01(\x08H\x00\x12\x19\n\x0fuser_preference\x18\x02 \x01(\x08H\x00\x42\x08\n\x06target\"\r\n\x0bLockCommand*\xe8\x02\n\tClosureId\x12\x1a\n\x16\x43LOSURE_ID_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x44OOR_FRONT_LEFT\x10\x01\x12\x14\n\x10\x44OOR_FRONT_RIGHT\x10\x02\x12\x12\n\x0e\x44OOR_REAR_LEFT\x10\x03\x12\x13\n\x0f\x44OOR_REAR_RIGHT\x10\x04\x12\t\n\x05\x46RUNK\x10\x05\x12\x0c\n\x08TAILGATE\x10\x06\x12\x0c\n\x08LIFTGATE\x10\x07\x12\x11\n\rSIDE_BIN_LEFT\x10\x08\x12\x12\n\x0eSIDE_BIN_RIGHT\x10\t\x12\x0f\n\x0b\x43HARGE_PORT\x10\n\x12\x0b\n\x07TONNEAU\x10\x0b\x12\x15\n\x11WINDOW_FRONT_LEFT\x10\x0c\x12\x16\n\x12WINDOW_FRONT_RIGHT\x10\r\x12\x14\n\x10WINDOW_REAR_LEFT\x10\x0e\x12\x15\n\x11WINDOW_REAR_RIGHT\x10\x0f\x12\x0f\n\x0bWINDOW_REAR\x10\x10\x12\x12\n\rGROUP_WINDOWS\x10\x90N*\xad\x01\n\x0c\x43losureState\x12\x1d\n\x19\x43LOSURE_STATE_UNSPECIFIED\x10\x00\x12\x16\n\x12\x43LOSURE_STATE_OPEN\x10\x01\x12\x18\n\x14\x43LOSURE_STATE_CLOSED\x10\x02\x12\x16\n\x12\x43LOSURE_STATE_AJAR\x10\x03\x12\x19\n\x15\x43LOSURE_STATE_OPENING\x10\x04\x12\x19\n\x15\x43LOSURE_STATE_CLOSING\x10\x05*\xf3\x02\n\x06LockId\x12\x17\n\x13LOCK_ID_UNSPECIFIED\x10\x00\x12\x18\n\x14LOCK_DOOR_FRONT_LEFT\x10\x01\x12\x19\n\x15LOCK_DOOR_FRONT_RIGHT\x10\x02\x12\x17\n\x13LOCK_DOOR_REAR_LEFT\x10\x03\x12\x18\n\x14LOCK_DOOR_REAR_RIGHT\x10\x04\x12\x0e\n\nLOCK_FRUNK\x10\x05\x12\x11\n\rLOCK_TAILGATE\x10\x06\x12\x11\n\rLOCK_LIFTGATE\x10\x07\x12\x16\n\x12LOCK_SIDE_BIN_LEFT\x10\x08\x12\x17\n\x13LOCK_SIDE_BIN_RIGHT\x10\t\x12\x14\n\x10LOCK_CHARGE_PORT\x10\n\x12\x17\n\x13LOCK_TRUNK_SECURITY\x10\x0b\x12\x17\n\x13LOCK_CENTER_CONSOLE\x10\x0c\x12\x12\n\x0eLOCK_GLOVE_BOX\x10\r\x12\x13\n\x0fLOCK_GEAR_GUARD\x10\x0e\x12\x10\n\x0cLOCK_TONNEAU\x10\x0f*z\n\tLockState\x12\x1a\n\x16LOCK_STATE_UNSPECIFIED\x10\x00\x12\x15\n\x11LOCK_STATE_LOCKED\x10\x01\x12\x17\n\x13LOCK_STATE_UNLOCKED\x10\x02\x12!\n\x1dLOCK_STATE_PARTIALLY_UNLOCKED\x10\x03*?\n\tLockFault\x12\x1a\n\x16LOCK_FAULT_UNSPECIFIED\x10\x00\x12\x16\n\x12LOCK_FAULT_FAULTED\x10\x01*\xcb\x01\n\x0eWindowInstance\x12\x1f\n\x1bWINDOW_INSTANCE_UNSPECIFIED\x10\x00\x12\x1e\n\x1aWINDOW_INSTANCE_FRONT_LEFT\x10\x01\x12\x1f\n\x1bWINDOW_INSTANCE_FRONT_RIGHT\x10\x02\x12\x1d\n\x19WINDOW_INSTANCE_REAR_LEFT\x10\x03\x12\x1e\n\x1aWINDOW_INSTANCE_REAR_RIGHT\x10\x04\x12\x18\n\x14WINDOW_INSTANCE_REAR\x10\x05*\x81\x01\n\x11\x43\x61librationStatus\x12\"\n\x1e\x43\x41LIBRATION_STATUS_UNSPECIFIED\x10\x00\x12!\n\x1d\x43\x41LIBRATION_STATUS_CALIBRATED\x10\x01\x12%\n!CALIBRATION_STATUS_NOT_CALIBRATED\x10\x02*\xd8\x01\n\x0fRearHitchStatus\x12!\n\x1dREAR_HITCH_STATUS_UNSPECIFIED\x10\x00\x12!\n\x1dREAR_HITCH_STATUS_NOT_PRESENT\x10\x01\x12\x1f\n\x1bREAR_HITCH_STATUS_ACCESSORY\x10\x02\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER1\x10\x03\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER2\x10\x04\x12\x1e\n\x1aREAR_HITCH_STATUS_TRAILER3\x10\x05*\xaa\x01\n\x0c\x43losureFault\x12\x1d\n\x19\x43LOSURE_FAULT_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LOSURE_FAULT_NO_FAULT\x10\x01\x12\x19\n\x15\x43LOSURE_FAULT_GENERAL\x10\x02\x12&\n\"CLOSURE_FAULT_NO_POWERED_OPERATION\x10\x03\x12\x1c\n\x18\x43LOSURE_FAULT_OBSTRUCTED\x10\x04*\x97\x01\n\x0fTrailerPresence\x12 \n\x1cTRAILER_PRESENCE_UNSPECIFIED\x10\x00\x12\x17\n\x13TRAILER_NOT_PRESENT\x10\x01\x12\x13\n\x0fTRAILER_PRESENT\x10\x02\x12\x1f\n\x1bTRAILER_PRESENT_WITH_BRAKES\x10\x03\x12\x13\n\x0fTRAILER_INVALID\x10\x04*\x9f\x04\n\x18\x43hargePortDoorNextAction\x12\x18\n\x14\x43HARGE_PORT_DOOR_SNA\x10\x00\x12!\n\x1d\x43HARGE_PORT_DOOR_OPEN_ALLOWED\x10\x01\x12\'\n#CHARGE_PORT_DOOR_OPEN_NOT_AVAILABLE\x10\x02\x12-\n)CHARGE_PORT_DOOR_OPEN_NOT_ALLOWED_FAULTED\x10\x03\x12\x1c\n\x18\x43HARGE_PORT_DOOR_OPENING\x10\x04\x12\"\n\x1e\x43HARGE_PORT_DOOR_CLOSE_ALLOWED\x10\x05\x12;\n7CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_OPENING_CLOSE_ALLOWED\x10\x06\x12:\n6CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_OPENING_OPEN_ALLOWED\x10\x07\x12;\n7CHARGE_PORT_DOOR_OBSTRUCTED_WHILE_CLOSING_CLOSE_ALLOWED\x10\x08\x12(\n$CHARGE_PORT_DOOR_CLOSE_NOT_AVAILABLE\x10\t\x12.\n*CHARGE_PORT_DOOR_CLOSE_NOT_ALLOWED_FAULTED\x10\n\x12\x1c\n\x18\x43HARGE_PORT_DOOR_CLOSING\x10\x0b*\xb0\x03\n\x0f\x46runkNextAction\x12\r\n\tFRUNK_SNA\x10\x00\x12\x16\n\x12\x46RUNK_OPEN_ALLOWED\x10\x01\x12\x17\n\x13\x46RUNK_CLOSE_ALLOWED\x10\x02\x12\x11\n\rFRUNK_OPENING\x10\x03\x12\x11\n\rFRUNK_CLOSING\x10\x04\x12\x1c\n\x18\x46RUNK_OPEN_NOT_AVAILABLE\x10\x05\x12\x1d\n\x19\x46RUNK_CLOSE_NOT_AVAILABLE\x10\x06\x12\"\n\x1e\x46RUNK_OPEN_NOT_ALLOWED_FAULTED\x10\x07\x12#\n\x1f\x46RUNK_CLOSE_NOT_ALLOWED_FAULTED\x10\x08\x12)\n%FRUNK_OPEN_ALLOWED_NO_POWER_OPERATION\x10\t\x12.\n*FRUNK_CLOSE_NOT_ALLOWED_NO_POWER_OPERATION\x10\n\x12*\n&FRUNK_OBSTRUCTED_OPENING_CLOSE_ALLOWED\x10\x0b\x12*\n&FRUNK_OBSTRUCTED_CLOSING_CLOSE_ALLOWED\x10\x0c*\xa7\x06\n\x12LiftgateNextAction\x12\x10\n\x0cLIFTGATE_SNA\x10\x00\x12\x19\n\x15LIFTGATE_OPEN_ALLOWED\x10\x01\x12\x1a\n\x16LIFTGATE_CLOSE_ALLOWED\x10\x02\x12\x14\n\x10LIFTGATE_OPENING\x10\x03\x12\x14\n\x10LIFTGATE_CLOSING\x10\x04\x12\x1f\n\x1bLIFTGATE_OPEN_NOT_AVAILABLE\x10\x05\x12 \n\x1cLIFTGATE_CLOSE_NOT_AVAILABLE\x10\x06\x12%\n!LIFTGATE_OPEN_NOT_ALLOWED_FAULTED\x10\x07\x12&\n\"LIFTGATE_CLOSE_NOT_ALLOWED_FAULTED\x10\x08\x12,\n(LIFTGATE_OPEN_ALLOWED_NO_POWER_OPERATION\x10\t\x12\x31\n-LIFTGATE_CLOSE_NOT_ALLOWED_NO_POWER_OPERATION\x10\n\x12-\n)LIFTGATE_OBSTRUCTED_OPENING_CLOSE_ALLOWED\x10\x0b\x12-\n)LIFTGATE_OBSTRUCTED_CLOSING_CLOSE_ALLOWED\x10\x0c\x12.\n*LIFTGATE_LOWER_GATE_OPEN_CLOSE_NOT_ALLOWED\x10\r\x12&\n\"LIFTGATE_OPENING_PAUSE_NOT_ALLOWED\x10\x0e\x12&\n\"LIFTGATE_CLOSING_PAUSE_NOT_ALLOWED\x10\x0f\x12+\n\'LIFTGATE_OPEN_ALLOWED_OBSTACLE_DETECTED\x10\x10\x12*\n&LIFTGATE_OPEN_ALLOWED_TRAILER_DETECTED\x10\x11\x12,\n(LIFTGATE_CLOSE_ALLOWED_OBSTACLE_DETECTED\x10\x12\x12+\n\'LIFTGATE_CLOSE_ALLOWED_TRAILER_DETECTED\x10\x13\x12\x17\n\x13LIFTGATE_PROCESSING\x10\x14*\xb2\x02\n\x11SideBinNextAction\x12\x10\n\x0cSIDE_BIN_SNA\x10\x00\x12\x19\n\x15SIDE_BIN_OPEN_ALLOWED\x10\x01\x12\x14\n\x10SIDE_BIN_OPENING\x10\x02\x12\x1f\n\x1bSIDE_BIN_OPEN_NOT_AVAILABLE\x10\x03\x12%\n!SIDE_BIN_OPEN_NOT_ALLOWED_FAULTED\x10\x04\x12\x32\n.SIDE_BIN_STUCK_AJAR_WHILE_OPENING_OPEN_ALLOWED\x10\x05\x12-\n)SIDE_BIN_OPEN_ALREADY_NO_ACTION_AVAILABLE\x10\x06\x12/\n+SIDE_BIN_OPEN_ALLOWED_CONFIRM_VEHICLE_ANGLE\x10\x07*\x8c\x03\n\x12TailgateNextAction\x12\x10\n\x0cTAILGATE_SNA\x10\x00\x12\x19\n\x15TAILGATE_OPEN_ALLOWED\x10\x01\x12\x14\n\x10TAILGATE_OPENING\x10\x02\x12\x1f\n\x1bTAILGATE_OPEN_NOT_AVAILABLE\x10\x03\x12%\n!TAILGATE_OPEN_NOT_ALLOWED_FAULTED\x10\x04\x12\x32\n.TAILGATE_STUCK_AJAR_WHILE_OPENING_OPEN_ALLOWED\x10\x05\x12-\n)TAILGATE_OPEN_ALREADY_NO_ACTION_AVAILABLE\x10\x06\x12/\n+TAILGATE_OPEN_ALLOWED_CONFIRM_VEHICLE_ANGLE\x10\x07\x12+\n\'TAILGATE_OPEN_ALLOWED_OBSTACLE_DETECTED\x10\x08\x12*\n&TAILGATE_OPEN_ALLOWED_TRAILER_DETECTED\x10\t*\xb0\x03\n\x11WindowsNextAction\x12\x0f\n\x0bWINDOWS_SNA\x10\x00\x12\x18\n\x14WINDOWS_OPEN_ALLOWED\x10\x01\x12\x19\n\x15WINDOWS_CLOSE_ALLOWED\x10\x02\x12\x13\n\x0fWINDOWS_OPENING\x10\x03\x12\x13\n\x0fWINDOWS_CLOSING\x10\x04\x12\x12\n\x0eWINDOWS_MOVING\x10\x05\x12\x1e\n\x1aWINDOWS_OPEN_NOT_AVAILABLE\x10\x06\x12\x1f\n\x1bWINDOWS_CLOSE_NOT_AVAILABLE\x10\x07\x12$\n WINDOWS_OPEN_NOT_ALLOWED_FAULTED\x10\x08\x12%\n!WINDOWS_CLOSE_NOT_ALLOWED_FAULTED\x10\t\x12\x32\n.WINDOWS_OBSTRUCTED_WHILE_CLOSING_CLOSE_ALLOWED\x10\n\x12*\n&WINDOWS_CLOSE_NOT_ALLOWED_UNCALIBRATED\x10\x0b\x12)\n%WINDOWS_OPEN_NOT_ALLOWED_UNCALIBRATED\x10\x0c*\x8a\x01\n\x0fWiperFluidState\x12!\n\x1dWIPER_FLUID_STATE_UNSPECIFIED\x10\x00\x12\x1c\n\x18WIPER_FLUID_STATE_NORMAL\x10\x01\x12\x19\n\x15WIPER_FLUID_STATE_LOW\x10\x02\x12\x1b\n\x17WIPER_FLUID_STATE_EMPTY\x10\x03\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rivian.parallax.proto.body_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None - _globals['_CLOSUREID']._serialized_start=1596 - _globals['_CLOSUREID']._serialized_end=1956 - _globals['_CLOSURESTATE']._serialized_start=1959 - _globals['_CLOSURESTATE']._serialized_end=2132 - _globals['_LOCKID']._serialized_start=2135 - _globals['_LOCKID']._serialized_end=2506 - _globals['_LOCKSTATE']._serialized_start=2508 - _globals['_LOCKSTATE']._serialized_end=2630 - _globals['_LOCKFAULT']._serialized_start=2632 - _globals['_LOCKFAULT']._serialized_end=2695 - _globals['_WINDOWINSTANCE']._serialized_start=2698 - _globals['_WINDOWINSTANCE']._serialized_end=2901 - _globals['_CALIBRATIONSTATUS']._serialized_start=2904 - _globals['_CALIBRATIONSTATUS']._serialized_end=3033 - _globals['_REARHITCHSTATUS']._serialized_start=3036 - _globals['_REARHITCHSTATUS']._serialized_end=3252 - _globals['_CLOSUREFAULT']._serialized_start=3255 - _globals['_CLOSUREFAULT']._serialized_end=3425 - _globals['_TRAILERPRESENCE']._serialized_start=3428 - _globals['_TRAILERPRESENCE']._serialized_end=3579 - _globals['_CHARGEPORTDOORNEXTACTION']._serialized_start=3582 - _globals['_CHARGEPORTDOORNEXTACTION']._serialized_end=4125 - _globals['_FRUNKNEXTACTION']._serialized_start=4128 - _globals['_FRUNKNEXTACTION']._serialized_end=4560 - _globals['_LIFTGATENEXTACTION']._serialized_start=4563 - _globals['_LIFTGATENEXTACTION']._serialized_end=5370 - _globals['_SIDEBINNEXTACTION']._serialized_start=5373 - _globals['_SIDEBINNEXTACTION']._serialized_end=5679 - _globals['_TAILGATENEXTACTION']._serialized_start=5682 - _globals['_TAILGATENEXTACTION']._serialized_end=6078 - _globals['_WINDOWSNEXTACTION']._serialized_start=6081 - _globals['_WINDOWSNEXTACTION']._serialized_end=6513 - _globals['_WIPERFLUIDSTATE']._serialized_start=6516 - _globals['_WIPERFLUIDSTATE']._serialized_end=6654 + _globals['_CLOSUREID']._serialized_start=1666 + _globals['_CLOSUREID']._serialized_end=2026 + _globals['_CLOSURESTATE']._serialized_start=2029 + _globals['_CLOSURESTATE']._serialized_end=2202 + _globals['_LOCKID']._serialized_start=2205 + _globals['_LOCKID']._serialized_end=2576 + _globals['_LOCKSTATE']._serialized_start=2578 + _globals['_LOCKSTATE']._serialized_end=2700 + _globals['_LOCKFAULT']._serialized_start=2702 + _globals['_LOCKFAULT']._serialized_end=2765 + _globals['_WINDOWINSTANCE']._serialized_start=2768 + _globals['_WINDOWINSTANCE']._serialized_end=2971 + _globals['_CALIBRATIONSTATUS']._serialized_start=2974 + _globals['_CALIBRATIONSTATUS']._serialized_end=3103 + _globals['_REARHITCHSTATUS']._serialized_start=3106 + _globals['_REARHITCHSTATUS']._serialized_end=3322 + _globals['_CLOSUREFAULT']._serialized_start=3325 + _globals['_CLOSUREFAULT']._serialized_end=3495 + _globals['_TRAILERPRESENCE']._serialized_start=3498 + _globals['_TRAILERPRESENCE']._serialized_end=3649 + _globals['_CHARGEPORTDOORNEXTACTION']._serialized_start=3652 + _globals['_CHARGEPORTDOORNEXTACTION']._serialized_end=4195 + _globals['_FRUNKNEXTACTION']._serialized_start=4198 + _globals['_FRUNKNEXTACTION']._serialized_end=4630 + _globals['_LIFTGATENEXTACTION']._serialized_start=4633 + _globals['_LIFTGATENEXTACTION']._serialized_end=5440 + _globals['_SIDEBINNEXTACTION']._serialized_start=5443 + _globals['_SIDEBINNEXTACTION']._serialized_end=5749 + _globals['_TAILGATENEXTACTION']._serialized_start=5752 + _globals['_TAILGATENEXTACTION']._serialized_end=6148 + _globals['_WINDOWSNEXTACTION']._serialized_start=6151 + _globals['_WINDOWSNEXTACTION']._serialized_end=6583 + _globals['_WIPERFLUIDSTATE']._serialized_start=6586 + _globals['_WIPERFLUIDSTATE']._serialized_end=6724 _globals['_CLOSURESSTATE']._serialized_start=59 _globals['_CLOSURESSTATE']._serialized_end=836 _globals['_CLOSURESSTATE_CLOSURE']._serialized_start=139 _globals['_CLOSURESSTATE_CLOSURE']._serialized_end=836 - _globals['_LOCKSSTATE']._serialized_start=839 - _globals['_LOCKSSTATE']._serialized_end=1066 - _globals['_LOCKSSTATE_LOCK']._serialized_start=907 - _globals['_LOCKSSTATE_LOCK']._serialized_end=1066 - _globals['_WINDOWSSTATE']._serialized_start=1069 - _globals['_WINDOWSSTATE']._serialized_end=1278 - _globals['_WINDOWSSTATE_WINDOW']._serialized_start=1145 - _globals['_WINDOWSSTATE_WINDOW']._serialized_end=1278 - _globals['_TRAILERSTATE']._serialized_start=1281 - _globals['_TRAILERSTATE']._serialized_end=1436 - _globals['_WIPERFLUIDLEVEL']._serialized_start=1438 - _globals['_WIPERFLUIDLEVEL']._serialized_end=1509 - _globals['_UNLOCKCOMMAND']._serialized_start=1511 - _globals['_UNLOCKCOMMAND']._serialized_end=1578 - _globals['_LOCKCOMMAND']._serialized_start=1580 - _globals['_LOCKCOMMAND']._serialized_end=1593 + _globals['_CLOSURESREQUEST']._serialized_start=838 + _globals['_CLOSURESREQUEST']._serialized_end=906 + _globals['_LOCKSSTATE']._serialized_start=909 + _globals['_LOCKSSTATE']._serialized_end=1136 + _globals['_LOCKSSTATE_LOCK']._serialized_start=977 + _globals['_LOCKSSTATE_LOCK']._serialized_end=1136 + _globals['_WINDOWSSTATE']._serialized_start=1139 + _globals['_WINDOWSSTATE']._serialized_end=1348 + _globals['_WINDOWSSTATE_WINDOW']._serialized_start=1215 + _globals['_WINDOWSSTATE_WINDOW']._serialized_end=1348 + _globals['_TRAILERSTATE']._serialized_start=1351 + _globals['_TRAILERSTATE']._serialized_end=1506 + _globals['_WIPERFLUIDLEVEL']._serialized_start=1508 + _globals['_WIPERFLUIDLEVEL']._serialized_end=1579 + _globals['_UNLOCKCOMMAND']._serialized_start=1581 + _globals['_UNLOCKCOMMAND']._serialized_end=1648 + _globals['_LOCKCOMMAND']._serialized_start=1650 + _globals['_LOCKCOMMAND']._serialized_end=1663 # @@protoc_insertion_point(module_scope) diff --git a/src/rivian/parallax/proto/body_pb2.pyi b/src/rivian/parallax/proto/body_pb2.pyi index fca5a8f..22aa9eb 100644 --- a/src/rivian/parallax/proto/body_pb2.pyi +++ b/src/rivian/parallax/proto/body_pb2.pyi @@ -393,6 +393,12 @@ class ClosuresState(_message.Message): closure: _containers.RepeatedCompositeFieldContainer[ClosuresState.Closure] def __init__(self, closure: _Optional[_Iterable[_Union[ClosuresState.Closure, _Mapping]]] = ...) -> None: ... +class ClosuresRequest(_message.Message): + __slots__ = ("closures",) + CLOSURES_FIELD_NUMBER: _ClassVar[int] + closures: _containers.RepeatedScalarFieldContainer[ClosureId] + def __init__(self, closures: _Optional[_Iterable[_Union[ClosureId, str]]] = ...) -> None: ... + class LocksState(_message.Message): __slots__ = ("lock",) class Lock(_message.Message): diff --git a/src/rivian/parallax/proto/charging.proto b/src/rivian/parallax/proto/charging.proto index f9995a1..be8cbf0 100644 --- a/src/rivian/parallax/proto/charging.proto +++ b/src/rivian/parallax/proto/charging.proto @@ -237,3 +237,8 @@ enum ChargerStatus { message SessionPower { float power = 1; // kW } + +// charging.energy.set_charge_limit +message ChargeLimitRequest { + uint32 limit = 1; // percent +} diff --git a/src/rivian/parallax/proto/charging_pb2.py b/src/rivian/parallax/proto/charging_pb2.py index 37d0513..6017e1b 100644 --- a/src/rivian/parallax/proto/charging_pb2.py +++ b/src/rivian/parallax/proto/charging_pb2.py @@ -24,31 +24,31 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$rivian/parallax/proto/charging.proto\x12\x18rivian.parallax.charging\"\xe8\x04\n\x12ScheduleTimeWindow\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x43\n\x06window\x18\x02 \x01(\x0b\x32\x33.rivian.parallax.charging.ScheduleTimeWindow.Window\x1a\xbe\x02\n\x06Window\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x10\n\x08\x64uration\x18\x03 \x01(\x05\x12\x11\n\x04\x61mps\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12L\n\x08location\x18\x05 \x01(\x0b\x32:.rivian.parallax.charging.ScheduleTimeWindow.GeoCoordinate\x12I\n\tstart_day\x18\x06 \x01(\x0e\x32\x36.rivian.parallax.charging.ScheduleTimeWindow.DayOfWeek\x12G\n\x07\x65nd_day\x18\x07 \x01(\x0e\x32\x36.rivian.parallax.charging.ScheduleTimeWindow.DayOfWeekB\x07\n\x05_amps\x1a\x34\n\rGeoCoordinate\x12\x10\n\x08latitude\x18\x01 \x01(\x01\x12\x11\n\tlongitude\x18\x02 \x01(\x01\"\x84\x01\n\tDayOfWeek\x12\x1b\n\x17\x44\x41Y_OF_WEEK_UNSPECIFIED\x10\x00\x12\n\n\x06SUNDAY\x10\x01\x12\n\n\x06MONDAY\x10\x02\x12\x0b\n\x07TUESDAY\x10\x03\x12\r\n\tWEDNESDAY\x10\x04\x12\x0c\n\x08THURSDAY\x10\x05\x12\n\n\x06\x46RIDAY\x10\x06\x12\x0c\n\x08SATURDAY\x10\x07\"\xb6\x01\n\x13SessionNotification\x12\x1e\n\x16unexpected_stop_reason\x18\x01 \x01(\x05\x12\x44\n\rderate_status\x18\x02 \x01(\x0e\x32-.rivian.parallax.charging.ChargerDerateStatus\x12\x39\n\x0b\x66\x61ult_chime\x18\x03 \x01(\x0e\x32$.rivian.parallax.charging.FaultChime\"\\\n\x14SessionRemoteCommand\x12\x44\n\x0fstart_available\x18\x01 \x01(\x0e\x32+.rivian.parallax.charging.StartAvailability\"1\n\tSocSlider\x12\x16\n\tsoc_limit\x18\x01 \x01(\x05H\x00\x88\x01\x01\x42\x0c\n\n_soc_limit\"\x1f\n\nTripTarget\x12\x11\n\tsoc_limit\x18\x02 \x01(\x05\"\xf3\x01\n\x15SmartChargingSettings\x12S\n\x0eready_by_times\x18\x01 \x03(\x0b\x32;.rivian.parallax.charging.SmartChargingSettings.ReadyByTime\x12\x1c\n\x14\x63lean_energy_enabled\x18\x02 \x01(\x08\x1ag\n\x0bReadyByTime\x12\r\n\x05hours\x18\x01 \x01(\x05\x12\x0f\n\x07minutes\x18\x02 \x01(\x05\x12\x38\n\x04\x64\x61ys\x18\x03 \x03(\x0e\x32*.rivian.parallax.charging.SmartChargingDay\"\xf0\x01\n\x11SmartChargingInfo\x12K\n\x0bresume_time\x18\x01 \x01(\x0b\x32\x36.rivian.parallax.charging.SmartChargingInfo.ResumeTime\x12I\n\x0cnotification\x18\x02 \x01(\x0e\x32\x33.rivian.parallax.charging.SmartChargingNotification\x12\x15\n\rschedule_type\x18\x03 \x01(\x05\x1a,\n\nResumeTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\x12\r\n\x05nanos\x18\x02 \x01(\x05\"\x1a\n\x18WeightedChargingForecast\"\xda\x01\n\rSessionStatus\x12H\n\x10\x63onnection_state\x18\x01 \x01(\x0e\x32).rivian.parallax.charging.ConnectionStateH\x00\x88\x01\x01\x12\x44\n\x0e\x63harging_state\x18\x02 \x01(\x0e\x32\'.rivian.parallax.charging.ChargingStateH\x01\x88\x01\x01\x12\x11\n\tevse_type\x18\x03 \x01(\x05\x42\x13\n\x11_connection_stateB\x11\n\x0f_charging_state\"v\n\x0eTimeEstimation\x12\x42\n\x08validity\x18\x01 \x01(\x0e\x32\x30.rivian.parallax.charging.TimeEstimationValidity\x12 \n\x18\x65stimated_time_remaining\x18\x02 \x01(\x05\"\x83\x03\n\x0b\x45nergyState\x12\x44\n\x0e\x63harging_state\x18\x01 \x01(\x0e\x32\'.rivian.parallax.charging.ChargingStateH\x00\x88\x01\x01\x12\x44\n\x0e\x63harger_status\x18\x02 \x01(\x0e\x32\'.rivian.parallax.charging.ChargerStatusH\x01\x88\x01\x01\x12\x14\n\x07\x66ield_3\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12\r\n\x05power\x18\x04 \x01(\x02\x12\x14\n\x07\x66ield_8\x18\x08 \x01(\x05H\x03\x88\x01\x01\x12\x10\n\x08\x66ield_10\x18\n \x01(\t\x12H\n\x10\x63onnection_state\x18\x0b \x01(\x0e\x32).rivian.parallax.charging.ConnectionStateH\x04\x88\x01\x01\x42\x11\n\x0f_charging_stateB\x11\n\x0f_charger_statusB\n\n\x08_field_3B\n\n\x08_field_8B\x13\n\x11_connection_state\"\x1d\n\x0cSessionPower\x12\r\n\x05power\x18\x01 \x01(\x02*\xb2\x05\n\x13\x43hargerDerateStatus\x12\x16\n\x12\x44\x45RATE_STATUS_NONE\x10\x00\x12\x1e\n\x1a\x44\x45RATE_STATUS_WARM_ADAPTER\x10\x01\x12\x1e\n\x1a\x44\x45RATE_STATUS_DC_WARM_PLUG\x10\x02\x12\x1e\n\x1a\x44\x45RATE_STATUS_AC_WARM_PLUG\x10\x03\x12\x1f\n\x1b\x44\x45RATE_STATUS_EVSE_DERATING\x10\x04\x12\x1d\n\x19\x44\x45RATE_STATUS_NEARING_TOC\x10\x05\x12/\n+DERATE_STATUS_NEAR_TOC_LFP_BATT_CALIBRATING\x10\x06\x12\"\n\x1e\x44\x45RATE_STATUS_HVAC_PRIORITIZED\x10\x07\x12!\n\x1d\x44\x45RATE_STATUS_BATTERY_HEATING\x10\x08\x12!\n\x1d\x44\x45RATE_STATUS_BATTERY_COOLING\x10\t\x12\x32\n.DERATE_STATUS_CELL_THERMAL_LIM_COLD_NO_CURRENT\x10\n\x12\x31\n-DERATE_STATUS_CELL_THERMAL_LIM_HOT_NO_CURRENT\x10\x0b\x12\'\n#DERATE_STATUS_CELL_THERMAL_LIM_COLD\x10\x0c\x12&\n\"DERATE_STATUS_CELL_THERMAL_LIM_HOT\x10\r\x12+\n\'DERATE_STATUS_PACK_HARDWARE_THERMAL_LIM\x10\x0e\x12 \n\x1c\x44\x45RATE_STATUS_HIGH_SOC_SIGMA\x10\x0f\x12\"\n\x1e\x44\x45RATE_STATUS_HV_BATTERY_FAULT\x10\x10\x12\x1d\n\x19\x44\x45RATE_STATUS_DCAC_EXPORT\x10\x11*\xdb\x03\n\nFaultChime\x12\x14\n\x10\x46\x41ULT_CHIME_NONE\x10\x00\x12%\n!FAULT_CHIME_CHARGING_DISABLED_ALL\x10\x01\x12$\n FAULT_CHIME_CHARGING_DISABLED_DC\x10\x02\x12-\n)FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_DC\x10\x03\x12\x36\n2FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_GRADIENT_DC\x10\x04\x12$\n FAULT_CHIME_CHARGING_DEGRADED_DC\x10\x05\x12$\n FAULT_CHIME_CHARGING_DISABLED_AC\x10\x06\x12-\n)FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_AC\x10\x07\x12$\n FAULT_CHIME_CHARGING_DEGRADED_AC\x10\x08\x12\x34\n0FAULT_CHIME_CHARGING_DISABLED_PARTIAL_CONNECTION\x10\t\x12,\n(FAULT_CHIME_CHARGING_DISABLED_NOT_PARKED\x10\n*j\n\x11StartAvailability\x12\x1a\n\x16START_AVAILABILITY_SNA\x10\x00\x12\x1c\n\x18START_AVAILABILITY_FALSE\x10\x01\x12\x1b\n\x17START_AVAILABILITY_TRUE\x10\x02*\x97\x02\n\x10SmartChargingDay\x12\"\n\x1eSMART_CHARGING_DAY_UNSPECIFIED\x10\x00\x12\x1d\n\x19SMART_CHARGING_DAY_MONDAY\x10\x01\x12\x1e\n\x1aSMART_CHARGING_DAY_TUESDAY\x10\x02\x12 \n\x1cSMART_CHARGING_DAY_WEDNESDAY\x10\x03\x12\x1f\n\x1bSMART_CHARGING_DAY_THURSDAY\x10\x04\x12\x1d\n\x19SMART_CHARGING_DAY_FRIDAY\x10\x05\x12\x1f\n\x1bSMART_CHARGING_DAY_SATURDAY\x10\x06\x12\x1d\n\x19SMART_CHARGING_DAY_SUNDAY\x10\x07*\xbc\x02\n\x19SmartChargingNotification\x12#\n\x1fSMART_CHARGING_NOTIFICATION_SNA\x10\x00\x12:\n6SMART_CHARGING_NOTIFICATION_CHARGING_WITH_CLEAN_ENERGY\x10\x01\x12/\n+SMART_CHARGING_NOTIFICATION_CHARGING_PAUSED\x10\x02\x12<\n8SMART_CHARGING_NOTIFICATION_CLEAN_ENERGY_NOT_ENOUGH_TIME\x10\x03\x12O\nKSMART_CHARGING_NOTIFICATION_CLEAN_ENERGY_FORECAST_UNAVAILABLE_OR_INCOMPLETE\x10\x04*\xaf\x01\n\x0f\x43onnectionState\x12\x19\n\x15\x43ONNECTION_STATE_INIT\x10\x00\x12!\n\x1d\x43ONNECTION_STATE_DISCONNECTED\x10\x01\x12\x1e\n\x1a\x43ONNECTION_STATE_CONNECTED\x10\x02\x12\x1a\n\x16\x43ONNECTION_STATE_ERROR\x10\x03\x12\"\n\x1e\x43ONNECTION_STATE_V2L_CONNECTED\x10\x04*\xc4\x06\n\rChargingState\x12\x1e\n\x1a\x43HARGING_STATE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x43HARGING_READY\x10\x01\x12\x17\n\x13\x43HARGING_CONNECTING\x10\x02\x12\x13\n\x0f\x43HARGING_ACTIVE\x10\x03\x12\x15\n\x11\x43HARGING_COMPLETE\x10\x04\x12\x16\n\x12\x43HARGING_SCHEDULED\x10\x05\x12\x1a\n\x16\x43HARGING_VEHICLE_ERROR\x10\x06\x12\x1a\n\x16\x43HARGING_STATION_ERROR\x10\x07\x12\x19\n\x15\x43HARGING_USER_STOPPED\x10\x08\x12\x1c\n\x18\x43HARGING_STATION_STOPPED\x10\t\x12\x1a\n\x16\x43HARGING_PAYMENT_ERROR\x10\n\x12\x17\n\x13\x43HARGING_CERT_ERROR\x10\x0b\x12\x16\n\x12\x43HARGING_TLS_ERROR\x10\x0c\x12(\n$CHARGING_ERROR_AC_ADAPTER_USED_ON_DC\x10\r\x12(\n$CHARGING_ERROR_DC_ADAPTER_USED_ON_AC\x10\x0e\x12\'\n#CHARGING_ERROR_INCOMPATIBLE_CHARGER\x10\x0f\x12\x1c\n\x18\x43HARGING_SD_COMPENSATION\x10\x10\x12\x16\n\x12WAITING_ON_CHARGER\x10\x11\x12%\n!CHARGER_NOT_READY_OR_INCOMPATIBLE\x10\x12\x12\x1c\n\x18\x43HARGING_VEHICLE_STOPPED\x10\x13\x12+\n\'CHARGING_PAYMENT_ERROR_START_RIVIAN_APP\x10\x14\x12&\n\"CHARGING_TLS_ERROR_UNKNOWN_CHARGER\x10\x15\x12&\n\"CHARGING_TLS_ERROR_UNEXPECTED_FAIL\x10\x16\x12\'\n#CHARGING_TLS_ERROR_START_RIVIAN_APP\x10\x17\x12\"\n\x1e\x43HARGING_SMART_CHARGING_PAUSED\x10\x18\x12\"\n\x1e\x43HARGING_SMART_CHARGING_ACTIVE\x10\x19*\xb4\x01\n\x16TimeEstimationValidity\x12!\n\x1dTIME_ESTIMATION_VALIDITY_NONE\x10\x00\x12\"\n\x1eTIME_ESTIMATION_VALIDITY_VALID\x10\x01\x12$\n TIME_ESTIMATION_VALIDITY_INVALID\x10\x02\x12-\n)TIME_ESTIMATION_VALIDITY_PACK_DISCHARGING\x10\x03*\xa0\x01\n\rChargerStatus\x12\x1e\n\x1a\x43HARGER_STATUS_UNSPECIFIED\x10\x00\x12 \n\x1c\x43HARGER_STATUS_NOT_CONNECTED\x10\x01\x12&\n\"CHARGER_STATUS_CONNECTED_NO_CHARGE\x10\x02\x12%\n!CHARGER_STATUS_CONNECTED_CHARGING\x10\x03\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$rivian/parallax/proto/charging.proto\x12\x18rivian.parallax.charging\"\xe8\x04\n\x12ScheduleTimeWindow\x12\x0f\n\x07\x65nabled\x18\x01 \x01(\x08\x12\x43\n\x06window\x18\x02 \x01(\x0b\x32\x33.rivian.parallax.charging.ScheduleTimeWindow.Window\x1a\xbe\x02\n\x06Window\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x10\n\x08\x64uration\x18\x03 \x01(\x05\x12\x11\n\x04\x61mps\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12L\n\x08location\x18\x05 \x01(\x0b\x32:.rivian.parallax.charging.ScheduleTimeWindow.GeoCoordinate\x12I\n\tstart_day\x18\x06 \x01(\x0e\x32\x36.rivian.parallax.charging.ScheduleTimeWindow.DayOfWeek\x12G\n\x07\x65nd_day\x18\x07 \x01(\x0e\x32\x36.rivian.parallax.charging.ScheduleTimeWindow.DayOfWeekB\x07\n\x05_amps\x1a\x34\n\rGeoCoordinate\x12\x10\n\x08latitude\x18\x01 \x01(\x01\x12\x11\n\tlongitude\x18\x02 \x01(\x01\"\x84\x01\n\tDayOfWeek\x12\x1b\n\x17\x44\x41Y_OF_WEEK_UNSPECIFIED\x10\x00\x12\n\n\x06SUNDAY\x10\x01\x12\n\n\x06MONDAY\x10\x02\x12\x0b\n\x07TUESDAY\x10\x03\x12\r\n\tWEDNESDAY\x10\x04\x12\x0c\n\x08THURSDAY\x10\x05\x12\n\n\x06\x46RIDAY\x10\x06\x12\x0c\n\x08SATURDAY\x10\x07\"\xb6\x01\n\x13SessionNotification\x12\x1e\n\x16unexpected_stop_reason\x18\x01 \x01(\x05\x12\x44\n\rderate_status\x18\x02 \x01(\x0e\x32-.rivian.parallax.charging.ChargerDerateStatus\x12\x39\n\x0b\x66\x61ult_chime\x18\x03 \x01(\x0e\x32$.rivian.parallax.charging.FaultChime\"\\\n\x14SessionRemoteCommand\x12\x44\n\x0fstart_available\x18\x01 \x01(\x0e\x32+.rivian.parallax.charging.StartAvailability\"1\n\tSocSlider\x12\x16\n\tsoc_limit\x18\x01 \x01(\x05H\x00\x88\x01\x01\x42\x0c\n\n_soc_limit\"\x1f\n\nTripTarget\x12\x11\n\tsoc_limit\x18\x02 \x01(\x05\"\xf3\x01\n\x15SmartChargingSettings\x12S\n\x0eready_by_times\x18\x01 \x03(\x0b\x32;.rivian.parallax.charging.SmartChargingSettings.ReadyByTime\x12\x1c\n\x14\x63lean_energy_enabled\x18\x02 \x01(\x08\x1ag\n\x0bReadyByTime\x12\r\n\x05hours\x18\x01 \x01(\x05\x12\x0f\n\x07minutes\x18\x02 \x01(\x05\x12\x38\n\x04\x64\x61ys\x18\x03 \x03(\x0e\x32*.rivian.parallax.charging.SmartChargingDay\"\xf0\x01\n\x11SmartChargingInfo\x12K\n\x0bresume_time\x18\x01 \x01(\x0b\x32\x36.rivian.parallax.charging.SmartChargingInfo.ResumeTime\x12I\n\x0cnotification\x18\x02 \x01(\x0e\x32\x33.rivian.parallax.charging.SmartChargingNotification\x12\x15\n\rschedule_type\x18\x03 \x01(\x05\x1a,\n\nResumeTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\x12\r\n\x05nanos\x18\x02 \x01(\x05\"\x1a\n\x18WeightedChargingForecast\"\xda\x01\n\rSessionStatus\x12H\n\x10\x63onnection_state\x18\x01 \x01(\x0e\x32).rivian.parallax.charging.ConnectionStateH\x00\x88\x01\x01\x12\x44\n\x0e\x63harging_state\x18\x02 \x01(\x0e\x32\'.rivian.parallax.charging.ChargingStateH\x01\x88\x01\x01\x12\x11\n\tevse_type\x18\x03 \x01(\x05\x42\x13\n\x11_connection_stateB\x11\n\x0f_charging_state\"v\n\x0eTimeEstimation\x12\x42\n\x08validity\x18\x01 \x01(\x0e\x32\x30.rivian.parallax.charging.TimeEstimationValidity\x12 \n\x18\x65stimated_time_remaining\x18\x02 \x01(\x05\"\x83\x03\n\x0b\x45nergyState\x12\x44\n\x0e\x63harging_state\x18\x01 \x01(\x0e\x32\'.rivian.parallax.charging.ChargingStateH\x00\x88\x01\x01\x12\x44\n\x0e\x63harger_status\x18\x02 \x01(\x0e\x32\'.rivian.parallax.charging.ChargerStatusH\x01\x88\x01\x01\x12\x14\n\x07\x66ield_3\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12\r\n\x05power\x18\x04 \x01(\x02\x12\x14\n\x07\x66ield_8\x18\x08 \x01(\x05H\x03\x88\x01\x01\x12\x10\n\x08\x66ield_10\x18\n \x01(\t\x12H\n\x10\x63onnection_state\x18\x0b \x01(\x0e\x32).rivian.parallax.charging.ConnectionStateH\x04\x88\x01\x01\x42\x11\n\x0f_charging_stateB\x11\n\x0f_charger_statusB\n\n\x08_field_3B\n\n\x08_field_8B\x13\n\x11_connection_state\"\x1d\n\x0cSessionPower\x12\r\n\x05power\x18\x01 \x01(\x02\"#\n\x12\x43hargeLimitRequest\x12\r\n\x05limit\x18\x01 \x01(\r*\xb2\x05\n\x13\x43hargerDerateStatus\x12\x16\n\x12\x44\x45RATE_STATUS_NONE\x10\x00\x12\x1e\n\x1a\x44\x45RATE_STATUS_WARM_ADAPTER\x10\x01\x12\x1e\n\x1a\x44\x45RATE_STATUS_DC_WARM_PLUG\x10\x02\x12\x1e\n\x1a\x44\x45RATE_STATUS_AC_WARM_PLUG\x10\x03\x12\x1f\n\x1b\x44\x45RATE_STATUS_EVSE_DERATING\x10\x04\x12\x1d\n\x19\x44\x45RATE_STATUS_NEARING_TOC\x10\x05\x12/\n+DERATE_STATUS_NEAR_TOC_LFP_BATT_CALIBRATING\x10\x06\x12\"\n\x1e\x44\x45RATE_STATUS_HVAC_PRIORITIZED\x10\x07\x12!\n\x1d\x44\x45RATE_STATUS_BATTERY_HEATING\x10\x08\x12!\n\x1d\x44\x45RATE_STATUS_BATTERY_COOLING\x10\t\x12\x32\n.DERATE_STATUS_CELL_THERMAL_LIM_COLD_NO_CURRENT\x10\n\x12\x31\n-DERATE_STATUS_CELL_THERMAL_LIM_HOT_NO_CURRENT\x10\x0b\x12\'\n#DERATE_STATUS_CELL_THERMAL_LIM_COLD\x10\x0c\x12&\n\"DERATE_STATUS_CELL_THERMAL_LIM_HOT\x10\r\x12+\n\'DERATE_STATUS_PACK_HARDWARE_THERMAL_LIM\x10\x0e\x12 \n\x1c\x44\x45RATE_STATUS_HIGH_SOC_SIGMA\x10\x0f\x12\"\n\x1e\x44\x45RATE_STATUS_HV_BATTERY_FAULT\x10\x10\x12\x1d\n\x19\x44\x45RATE_STATUS_DCAC_EXPORT\x10\x11*\xdb\x03\n\nFaultChime\x12\x14\n\x10\x46\x41ULT_CHIME_NONE\x10\x00\x12%\n!FAULT_CHIME_CHARGING_DISABLED_ALL\x10\x01\x12$\n FAULT_CHIME_CHARGING_DISABLED_DC\x10\x02\x12-\n)FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_DC\x10\x03\x12\x36\n2FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_GRADIENT_DC\x10\x04\x12$\n FAULT_CHIME_CHARGING_DEGRADED_DC\x10\x05\x12$\n FAULT_CHIME_CHARGING_DISABLED_AC\x10\x06\x12-\n)FAULT_CHIME_CHARGING_DISABLED_PIN_TEMP_AC\x10\x07\x12$\n FAULT_CHIME_CHARGING_DEGRADED_AC\x10\x08\x12\x34\n0FAULT_CHIME_CHARGING_DISABLED_PARTIAL_CONNECTION\x10\t\x12,\n(FAULT_CHIME_CHARGING_DISABLED_NOT_PARKED\x10\n*j\n\x11StartAvailability\x12\x1a\n\x16START_AVAILABILITY_SNA\x10\x00\x12\x1c\n\x18START_AVAILABILITY_FALSE\x10\x01\x12\x1b\n\x17START_AVAILABILITY_TRUE\x10\x02*\x97\x02\n\x10SmartChargingDay\x12\"\n\x1eSMART_CHARGING_DAY_UNSPECIFIED\x10\x00\x12\x1d\n\x19SMART_CHARGING_DAY_MONDAY\x10\x01\x12\x1e\n\x1aSMART_CHARGING_DAY_TUESDAY\x10\x02\x12 \n\x1cSMART_CHARGING_DAY_WEDNESDAY\x10\x03\x12\x1f\n\x1bSMART_CHARGING_DAY_THURSDAY\x10\x04\x12\x1d\n\x19SMART_CHARGING_DAY_FRIDAY\x10\x05\x12\x1f\n\x1bSMART_CHARGING_DAY_SATURDAY\x10\x06\x12\x1d\n\x19SMART_CHARGING_DAY_SUNDAY\x10\x07*\xbc\x02\n\x19SmartChargingNotification\x12#\n\x1fSMART_CHARGING_NOTIFICATION_SNA\x10\x00\x12:\n6SMART_CHARGING_NOTIFICATION_CHARGING_WITH_CLEAN_ENERGY\x10\x01\x12/\n+SMART_CHARGING_NOTIFICATION_CHARGING_PAUSED\x10\x02\x12<\n8SMART_CHARGING_NOTIFICATION_CLEAN_ENERGY_NOT_ENOUGH_TIME\x10\x03\x12O\nKSMART_CHARGING_NOTIFICATION_CLEAN_ENERGY_FORECAST_UNAVAILABLE_OR_INCOMPLETE\x10\x04*\xaf\x01\n\x0f\x43onnectionState\x12\x19\n\x15\x43ONNECTION_STATE_INIT\x10\x00\x12!\n\x1d\x43ONNECTION_STATE_DISCONNECTED\x10\x01\x12\x1e\n\x1a\x43ONNECTION_STATE_CONNECTED\x10\x02\x12\x1a\n\x16\x43ONNECTION_STATE_ERROR\x10\x03\x12\"\n\x1e\x43ONNECTION_STATE_V2L_CONNECTED\x10\x04*\xc4\x06\n\rChargingState\x12\x1e\n\x1a\x43HARGING_STATE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x43HARGING_READY\x10\x01\x12\x17\n\x13\x43HARGING_CONNECTING\x10\x02\x12\x13\n\x0f\x43HARGING_ACTIVE\x10\x03\x12\x15\n\x11\x43HARGING_COMPLETE\x10\x04\x12\x16\n\x12\x43HARGING_SCHEDULED\x10\x05\x12\x1a\n\x16\x43HARGING_VEHICLE_ERROR\x10\x06\x12\x1a\n\x16\x43HARGING_STATION_ERROR\x10\x07\x12\x19\n\x15\x43HARGING_USER_STOPPED\x10\x08\x12\x1c\n\x18\x43HARGING_STATION_STOPPED\x10\t\x12\x1a\n\x16\x43HARGING_PAYMENT_ERROR\x10\n\x12\x17\n\x13\x43HARGING_CERT_ERROR\x10\x0b\x12\x16\n\x12\x43HARGING_TLS_ERROR\x10\x0c\x12(\n$CHARGING_ERROR_AC_ADAPTER_USED_ON_DC\x10\r\x12(\n$CHARGING_ERROR_DC_ADAPTER_USED_ON_AC\x10\x0e\x12\'\n#CHARGING_ERROR_INCOMPATIBLE_CHARGER\x10\x0f\x12\x1c\n\x18\x43HARGING_SD_COMPENSATION\x10\x10\x12\x16\n\x12WAITING_ON_CHARGER\x10\x11\x12%\n!CHARGER_NOT_READY_OR_INCOMPATIBLE\x10\x12\x12\x1c\n\x18\x43HARGING_VEHICLE_STOPPED\x10\x13\x12+\n\'CHARGING_PAYMENT_ERROR_START_RIVIAN_APP\x10\x14\x12&\n\"CHARGING_TLS_ERROR_UNKNOWN_CHARGER\x10\x15\x12&\n\"CHARGING_TLS_ERROR_UNEXPECTED_FAIL\x10\x16\x12\'\n#CHARGING_TLS_ERROR_START_RIVIAN_APP\x10\x17\x12\"\n\x1e\x43HARGING_SMART_CHARGING_PAUSED\x10\x18\x12\"\n\x1e\x43HARGING_SMART_CHARGING_ACTIVE\x10\x19*\xb4\x01\n\x16TimeEstimationValidity\x12!\n\x1dTIME_ESTIMATION_VALIDITY_NONE\x10\x00\x12\"\n\x1eTIME_ESTIMATION_VALIDITY_VALID\x10\x01\x12$\n TIME_ESTIMATION_VALIDITY_INVALID\x10\x02\x12-\n)TIME_ESTIMATION_VALIDITY_PACK_DISCHARGING\x10\x03*\xa0\x01\n\rChargerStatus\x12\x1e\n\x1a\x43HARGER_STATUS_UNSPECIFIED\x10\x00\x12 \n\x1c\x43HARGER_STATUS_NOT_CONNECTED\x10\x01\x12&\n\"CHARGER_STATUS_CONNECTED_NO_CHARGE\x10\x02\x12%\n!CHARGER_STATUS_CONNECTED_CHARGING\x10\x03\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rivian.parallax.proto.charging_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None - _globals['_CHARGERDERATESTATUS']._serialized_start=2328 - _globals['_CHARGERDERATESTATUS']._serialized_end=3018 - _globals['_FAULTCHIME']._serialized_start=3021 - _globals['_FAULTCHIME']._serialized_end=3496 - _globals['_STARTAVAILABILITY']._serialized_start=3498 - _globals['_STARTAVAILABILITY']._serialized_end=3604 - _globals['_SMARTCHARGINGDAY']._serialized_start=3607 - _globals['_SMARTCHARGINGDAY']._serialized_end=3886 - _globals['_SMARTCHARGINGNOTIFICATION']._serialized_start=3889 - _globals['_SMARTCHARGINGNOTIFICATION']._serialized_end=4205 - _globals['_CONNECTIONSTATE']._serialized_start=4208 - _globals['_CONNECTIONSTATE']._serialized_end=4383 - _globals['_CHARGINGSTATE']._serialized_start=4386 - _globals['_CHARGINGSTATE']._serialized_end=5222 - _globals['_TIMEESTIMATIONVALIDITY']._serialized_start=5225 - _globals['_TIMEESTIMATIONVALIDITY']._serialized_end=5405 - _globals['_CHARGERSTATUS']._serialized_start=5408 - _globals['_CHARGERSTATUS']._serialized_end=5568 + _globals['_CHARGERDERATESTATUS']._serialized_start=2365 + _globals['_CHARGERDERATESTATUS']._serialized_end=3055 + _globals['_FAULTCHIME']._serialized_start=3058 + _globals['_FAULTCHIME']._serialized_end=3533 + _globals['_STARTAVAILABILITY']._serialized_start=3535 + _globals['_STARTAVAILABILITY']._serialized_end=3641 + _globals['_SMARTCHARGINGDAY']._serialized_start=3644 + _globals['_SMARTCHARGINGDAY']._serialized_end=3923 + _globals['_SMARTCHARGINGNOTIFICATION']._serialized_start=3926 + _globals['_SMARTCHARGINGNOTIFICATION']._serialized_end=4242 + _globals['_CONNECTIONSTATE']._serialized_start=4245 + _globals['_CONNECTIONSTATE']._serialized_end=4420 + _globals['_CHARGINGSTATE']._serialized_start=4423 + _globals['_CHARGINGSTATE']._serialized_end=5259 + _globals['_TIMEESTIMATIONVALIDITY']._serialized_start=5262 + _globals['_TIMEESTIMATIONVALIDITY']._serialized_end=5442 + _globals['_CHARGERSTATUS']._serialized_start=5445 + _globals['_CHARGERSTATUS']._serialized_end=5605 _globals['_SCHEDULETIMEWINDOW']._serialized_start=67 _globals['_SCHEDULETIMEWINDOW']._serialized_end=683 _globals['_SCHEDULETIMEWINDOW_WINDOW']._serialized_start=176 @@ -83,4 +83,6 @@ _globals['_ENERGYSTATE']._serialized_end=2294 _globals['_SESSIONPOWER']._serialized_start=2296 _globals['_SESSIONPOWER']._serialized_end=2325 + _globals['_CHARGELIMITREQUEST']._serialized_start=2327 + _globals['_CHARGELIMITREQUEST']._serialized_end=2362 # @@protoc_insertion_point(module_scope) diff --git a/src/rivian/parallax/proto/charging_pb2.pyi b/src/rivian/parallax/proto/charging_pb2.pyi index a46f6c6..460e004 100644 --- a/src/rivian/parallax/proto/charging_pb2.pyi +++ b/src/rivian/parallax/proto/charging_pb2.pyi @@ -359,3 +359,9 @@ class SessionPower(_message.Message): POWER_FIELD_NUMBER: _ClassVar[int] power: float def __init__(self, power: _Optional[float] = ...) -> None: ... + +class ChargeLimitRequest(_message.Message): + __slots__ = ("limit",) + LIMIT_FIELD_NUMBER: _ClassVar[int] + limit: int + def __init__(self, limit: _Optional[int] = ...) -> None: ... diff --git a/src/rivian/parallax/proto/comfort.proto b/src/rivian/parallax/proto/comfort.proto index 385ce24..8eb341a 100644 --- a/src/rivian/parallax/proto/comfort.proto +++ b/src/rivian/parallax/proto/comfort.proto @@ -133,6 +133,30 @@ enum DefrostStatus { DEFROST_OFF = 4; } +// comfort.cabin.set_defrost_defog +message DefrostDefogRequest { + DefrostStatus status = 1; // the app sends DEFROST_DEFOG_DEFROST or DEFROST_OFF +} + +// comfort.cabin.set_preconditioning_temperature +message PreconditioningTemperatureRequest { + optional float temperature = 1; // °C; sent even for 0 (LO) +} + +enum CabinSurfaceStatus { + CABIN_SURFACE_STATUS_UNSPECIFIED = 0; + CABIN_SURFACE_OFF = 1; + CABIN_SURFACE_ON = 2; +} + +// comfort.cabin.set_cabin_surface +message CabinSurfaceRequest { + CabinSurface surface = 1; + ConditioningLevel level = 2; + CabinSurfaceStatus status = 3; + ConditioningType type = 4; +} + // comfort.cabin.pet_mode_status message PetModeStatus { PetModeState status = 1; diff --git a/src/rivian/parallax/proto/comfort_pb2.py b/src/rivian/parallax/proto/comfort_pb2.py index 423b48d..40ec8d0 100644 --- a/src/rivian/parallax/proto/comfort_pb2.py +++ b/src/rivian/parallax/proto/comfort_pb2.py @@ -24,39 +24,41 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#rivian/parallax/proto/comfort.proto\x12\x17rivian.parallax.comfort\"0\n\x12HvacSettingsStatus\x12\x1a\n\x12target_temperature\x18\x01 \x01(\x02\"\xa4\x01\n\x0eUserModesState\x12\x12\n\nin_service\x18\x01 \x01(\x08\x12\x15\n\rcar_wash_mode\x18\x02 \x01(\x08\x12\x10\n\x08pet_mode\x18\x03 \x01(\x05\x12\x11\n\tcamp_mode\x18\x04 \x01(\x05\x12\x16\n\x0etransport_mode\x18\x05 \x01(\x05\x12\x14\n\x0c\x63limate_keep\x18\x06 \x01(\x05\x12\x14\n\x0c\x66\x61\x63tory_mode\x18\x07 \x01(\x05\"\x98\x01\n\x1a\x43\x61\x62inPreconditioningStatus\x12>\n\x06status\x18\x01 \x01(\x0e\x32..rivian.parallax.comfort.PreconditioningStatus\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.rivian.parallax.comfort.PreconditioningType\"\xa9\x02\n\x11\x43\x61\x62inTemperatures\x12P\n\x0ctemperatures\x18\x01 \x03(\x0b\x32:.rivian.parallax.comfort.CabinTemperatures.ZoneTemperature\x12!\n\x14\x65xterior_temperature\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x1c\n\x14interior_temperature\x18\x03 \x01(\x02\x12\x1d\n\x10\x64river_set_point\x18\x04 \x01(\x02H\x01\x88\x01\x01\x1a\x34\n\x0fZoneTemperature\x12\x0c\n\x04seat\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x42\x17\n\x15_exterior_temperatureB\x13\n\x11_driver_set_point\"A\n\x17\x43\x61\x62inVentilationSetting\x12&\n\x1e\x61uto_cabin_ventilation_enabled\x18\x01 \x01(\x08\"&\n\x12\x43limateHoldSetting\x12\x10\n\x08\x64uration\x18\x01 \x01(\x05\"@\n\rActionRequest\x12/\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32\x1f.rivian.parallax.comfort.Action\"\xd7\x02\n\x11\x43limateHoldStatus\x12?\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.comfort.ClimateHoldStatusValue\x12\x46\n\x0c\x61vailability\x18\x02 \x01(\x0e\x32\x30.rivian.parallax.comfort.ClimateHoldAvailability\x12W\n\x15unavailability_reason\x18\x03 \x01(\x0e\x32\x38.rivian.parallax.comfort.ClimateHoldUnavailabilityReason\x12\x44\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x32.rivian.parallax.comfort.ClimateHoldStatus.EndTime\x1a\x1a\n\x07\x45ndTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\"L\n\x12\x44\x65\x66rostDefogStatus\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.rivian.parallax.comfort.DefrostStatus\"\xda\x01\n\rPetModeStatus\x12\x35\n\x06status\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.PetModeState\x12M\n\x12temperature_status\x18\x02 \x01(\x0e\x32\x31.rivian.parallax.comfort.PetModeTemperatureStatus\x12\x43\n\rcabin_climate\x18\x03 \x01(\x0e\x32,.rivian.parallax.comfort.PetModeCabinClimate\"\xa4\x02\n\x16SeatConditioningStatus\x12H\n\x07surface\x18\x01 \x03(\x0b\x32\x37.rivian.parallax.comfort.SeatConditioningStatus.Surface\x1a\xbf\x01\n\x07Surface\x12\x31\n\x02id\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.CabinSurface\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).rivian.parallax.comfort.ConditioningType\x12>\n\x05state\x18\x03 \x01(\x0e\x32*.rivian.parallax.comfort.ConditioningLevelH\x00\x88\x01\x01\x42\x08\n\x06_state*\x85\x03\n\x15PreconditioningStatus\x12&\n\"PRECONDITIONING_STATUS_UNSPECIFIED\x10\x00\x12\x1c\n\x18PRECONDITIONING_INITIATE\x10\x01\x12\x1a\n\x16PRECONDITIONING_ACTIVE\x10\x02\x12\"\n\x1ePRECONDITIONING_ACTIVE_WARNING\x10\x03\x12%\n!PRECONDITIONING_COMPLETE_MAINTAIN\x10\x04\x12-\n)PRECONDITIONING_TIMEOUT_TEMP_NOT_ACHIEVED\x10\x05\x12!\n\x1dPRECONDITIONING_ERROR_SOC_LOW\x10\x06\x12&\n\"PRECONDITIONING_ERROR_SYSTEM_FAULT\x10\x07\x12\x1f\n\x1bPRECONDITIONING_UNAVAILABLE\x10\x08\x12$\n PRECONDITIONING_TIMEOUT_COMPLETE\x10\t*\xe4\x01\n\x13PreconditioningType\x12$\n PRECONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12&\n\"PRECONDITIONING_TYPE_USER_SELECTED\x10\x01\x12*\n&PRECONDITIONING_TYPE_SCREEN_PROTECTION\x10\x02\x12\"\n\x1ePRECONDITIONING_TYPE_SCHEDULED\x10\x03\x12/\n+PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION\x10\x04*?\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\r\n\tACTION_ON\x10\x01\x12\x0e\n\nACTION_OFF\x10\x02*\xba\x01\n\x16\x43limateHoldStatusValue\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNSPECIFIED\x10\x00\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNAVAILABLE\x10\x01\x12\x1b\n\x17\x43LIMATE_HOLD_STATUS_OFF\x10\x02\x12\x1a\n\x16\x43LIMATE_HOLD_STATUS_ON\x10\x03\x12\x1d\n\x19\x43LIMATE_HOLD_STATUS_FAULT\x10\x04*\x9d\x01\n\x17\x43limateHoldAvailability\x12)\n%CLIMATE_HOLD_AVAILABILITY_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LIMATE_HOLD_AVAILABLE\x10\x01\x12\x1d\n\x19\x43LIMATE_HOLD_CONTROLLABLE\x10\x02\x12\x1c\n\x18\x43LIMATE_HOLD_UNAVAILABLE\x10\x03*\xc7\x01\n\x1f\x43limateHoldUnavailabilityReason\x12+\n\'CLIMATE_HOLD_UNAVAILABILITY_UNSPECIFIED\x10\x00\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_UNKNOWN\x10\x01\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_LOW_SOC\x10\x02\x12%\n!CLIMATE_HOLD_UNAVAILABILITY_FAULT\x10\x03*\x82\x01\n\rDefrostStatus\x12\x1e\n\x1a\x44\x45\x46ROST_STATUS_UNSPECIFIED\x10\x00\x12\x11\n\rDEFROST_DEFOG\x10\x01\x12\x12\n\x0e\x44\x45\x46ROST_ACTIVE\x10\x02\x12\x19\n\x15\x44\x45\x46ROST_DEFOG_DEFROST\x10\x03\x12\x0f\n\x0b\x44\x45\x46ROST_OFF\x10\x04*~\n\x13PetModeCabinClimate\x12&\n\"PET_MODE_CABIN_CLIMATE_COMFORTABLE\x10\x00\x12\x1f\n\x1bPET_MODE_CABIN_CLIMATE_COLD\x10\x01\x12\x1e\n\x1aPET_MODE_CABIN_CLIMATE_HOT\x10\x02*]\n\x0cPetModeState\x12\x10\n\x0cPET_MODE_OFF\x10\x00\x12\x0f\n\x0bPET_MODE_ON\x10\x01\x12\x15\n\x11PET_MODE_DISABLED\x10\x02\x12\x13\n\x0fPET_MODE_FAULTY\x10\x03*\x9a\x01\n\x18PetModeTemperatureStatus\x12 \n\x1cPET_MODE_TEMPERATURE_DEFAULT\x10\x00\x12\x1d\n\x19PET_MODE_TEMPERATURE_COLD\x10\x01\x12\x1c\n\x18PET_MODE_TEMPERATURE_HOT\x10\x02\x12\x1f\n\x1bPET_MODE_TEMPERATURE_FAULTY\x10\x03*\xce\x02\n\x0c\x43\x61\x62inSurface\x12\x1d\n\x19\x43\x41\x42IN_SURFACE_UNSPECIFIED\x10\x00\x12\x12\n\x0eSTEERING_WHEEL\x10\x01\x12\x0e\n\nREAR_GLASS\x10\x02\x12\x0f\n\x0b\x46RONT_GLASS\x10\x03\x12\x14\n\x10SIDEVIEW_MIRRORS\x10\x04\x12\x13\n\x0fSEAT_ROW_1_LEFT\x10\x05\x12\x15\n\x11SEAT_ROW_1_MIDDLE\x10\x06\x12\x14\n\x10SEAT_ROW_1_RIGHT\x10\x07\x12\x13\n\x0fSEAT_ROW_2_LEFT\x10\x08\x12\x15\n\x11SEAT_ROW_2_MIDDLE\x10\t\x12\x14\n\x10SEAT_ROW_2_RIGHT\x10\n\x12\x13\n\x0fSEAT_ROW_3_LEFT\x10\x0b\x12\x15\n\x11SEAT_ROW_3_MIDDLE\x10\x0c\x12\x14\n\x10SEAT_ROW_3_RIGHT\x10\r\x12\x0e\n\nWIPER_AREA\x10\x0e*c\n\x10\x43onditioningType\x12!\n\x1d\x43ONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43ONDITIONING_HEAT\x10\x01\x12\x15\n\x11\x43ONDITIONING_VENT\x10\x02*\x85\x01\n\x11\x43onditioningLevel\x12\"\n\x1e\x43ONDITIONING_LEVEL_UNSPECIFIED\x10\x00\x12\x18\n\x14\x43ONDITIONING_LEVEL_1\x10\x01\x12\x18\n\x14\x43ONDITIONING_LEVEL_2\x10\x02\x12\x18\n\x14\x43ONDITIONING_LEVEL_3\x10\x03\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#rivian/parallax/proto/comfort.proto\x12\x17rivian.parallax.comfort\"0\n\x12HvacSettingsStatus\x12\x1a\n\x12target_temperature\x18\x01 \x01(\x02\"\xa4\x01\n\x0eUserModesState\x12\x12\n\nin_service\x18\x01 \x01(\x08\x12\x15\n\rcar_wash_mode\x18\x02 \x01(\x08\x12\x10\n\x08pet_mode\x18\x03 \x01(\x05\x12\x11\n\tcamp_mode\x18\x04 \x01(\x05\x12\x16\n\x0etransport_mode\x18\x05 \x01(\x05\x12\x14\n\x0c\x63limate_keep\x18\x06 \x01(\x05\x12\x14\n\x0c\x66\x61\x63tory_mode\x18\x07 \x01(\x05\"\x98\x01\n\x1a\x43\x61\x62inPreconditioningStatus\x12>\n\x06status\x18\x01 \x01(\x0e\x32..rivian.parallax.comfort.PreconditioningStatus\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.rivian.parallax.comfort.PreconditioningType\"\xa9\x02\n\x11\x43\x61\x62inTemperatures\x12P\n\x0ctemperatures\x18\x01 \x03(\x0b\x32:.rivian.parallax.comfort.CabinTemperatures.ZoneTemperature\x12!\n\x14\x65xterior_temperature\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x1c\n\x14interior_temperature\x18\x03 \x01(\x02\x12\x1d\n\x10\x64river_set_point\x18\x04 \x01(\x02H\x01\x88\x01\x01\x1a\x34\n\x0fZoneTemperature\x12\x0c\n\x04seat\x18\x01 \x01(\x05\x12\x13\n\x0btemperature\x18\x02 \x01(\x02\x42\x17\n\x15_exterior_temperatureB\x13\n\x11_driver_set_point\"A\n\x17\x43\x61\x62inVentilationSetting\x12&\n\x1e\x61uto_cabin_ventilation_enabled\x18\x01 \x01(\x08\"&\n\x12\x43limateHoldSetting\x12\x10\n\x08\x64uration\x18\x01 \x01(\x05\"@\n\rActionRequest\x12/\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32\x1f.rivian.parallax.comfort.Action\"\xd7\x02\n\x11\x43limateHoldStatus\x12?\n\x06status\x18\x01 \x01(\x0e\x32/.rivian.parallax.comfort.ClimateHoldStatusValue\x12\x46\n\x0c\x61vailability\x18\x02 \x01(\x0e\x32\x30.rivian.parallax.comfort.ClimateHoldAvailability\x12W\n\x15unavailability_reason\x18\x03 \x01(\x0e\x32\x38.rivian.parallax.comfort.ClimateHoldUnavailabilityReason\x12\x44\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x32.rivian.parallax.comfort.ClimateHoldStatus.EndTime\x1a\x1a\n\x07\x45ndTime\x12\x0f\n\x07seconds\x18\x01 \x01(\x03\"L\n\x12\x44\x65\x66rostDefogStatus\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.rivian.parallax.comfort.DefrostStatus\"M\n\x13\x44\x65\x66rostDefogRequest\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.rivian.parallax.comfort.DefrostStatus\"M\n!PreconditioningTemperatureRequest\x12\x18\n\x0btemperature\x18\x01 \x01(\x02H\x00\x88\x01\x01\x42\x0e\n\x0c_temperature\"\xfe\x01\n\x13\x43\x61\x62inSurfaceRequest\x12\x36\n\x07surface\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.CabinSurface\x12\x39\n\x05level\x18\x02 \x01(\x0e\x32*.rivian.parallax.comfort.ConditioningLevel\x12;\n\x06status\x18\x03 \x01(\x0e\x32+.rivian.parallax.comfort.CabinSurfaceStatus\x12\x37\n\x04type\x18\x04 \x01(\x0e\x32).rivian.parallax.comfort.ConditioningType\"\xda\x01\n\rPetModeStatus\x12\x35\n\x06status\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.PetModeState\x12M\n\x12temperature_status\x18\x02 \x01(\x0e\x32\x31.rivian.parallax.comfort.PetModeTemperatureStatus\x12\x43\n\rcabin_climate\x18\x03 \x01(\x0e\x32,.rivian.parallax.comfort.PetModeCabinClimate\"\xa4\x02\n\x16SeatConditioningStatus\x12H\n\x07surface\x18\x01 \x03(\x0b\x32\x37.rivian.parallax.comfort.SeatConditioningStatus.Surface\x1a\xbf\x01\n\x07Surface\x12\x31\n\x02id\x18\x01 \x01(\x0e\x32%.rivian.parallax.comfort.CabinSurface\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).rivian.parallax.comfort.ConditioningType\x12>\n\x05state\x18\x03 \x01(\x0e\x32*.rivian.parallax.comfort.ConditioningLevelH\x00\x88\x01\x01\x42\x08\n\x06_state*\x85\x03\n\x15PreconditioningStatus\x12&\n\"PRECONDITIONING_STATUS_UNSPECIFIED\x10\x00\x12\x1c\n\x18PRECONDITIONING_INITIATE\x10\x01\x12\x1a\n\x16PRECONDITIONING_ACTIVE\x10\x02\x12\"\n\x1ePRECONDITIONING_ACTIVE_WARNING\x10\x03\x12%\n!PRECONDITIONING_COMPLETE_MAINTAIN\x10\x04\x12-\n)PRECONDITIONING_TIMEOUT_TEMP_NOT_ACHIEVED\x10\x05\x12!\n\x1dPRECONDITIONING_ERROR_SOC_LOW\x10\x06\x12&\n\"PRECONDITIONING_ERROR_SYSTEM_FAULT\x10\x07\x12\x1f\n\x1bPRECONDITIONING_UNAVAILABLE\x10\x08\x12$\n PRECONDITIONING_TIMEOUT_COMPLETE\x10\t*\xe4\x01\n\x13PreconditioningType\x12$\n PRECONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12&\n\"PRECONDITIONING_TYPE_USER_SELECTED\x10\x01\x12*\n&PRECONDITIONING_TYPE_SCREEN_PROTECTION\x10\x02\x12\"\n\x1ePRECONDITIONING_TYPE_SCHEDULED\x10\x03\x12/\n+PRECONDITIONING_TYPE_AUTO_CABIN_VENTILATION\x10\x04*?\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\r\n\tACTION_ON\x10\x01\x12\x0e\n\nACTION_OFF\x10\x02*\xba\x01\n\x16\x43limateHoldStatusValue\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNSPECIFIED\x10\x00\x12#\n\x1f\x43LIMATE_HOLD_STATUS_UNAVAILABLE\x10\x01\x12\x1b\n\x17\x43LIMATE_HOLD_STATUS_OFF\x10\x02\x12\x1a\n\x16\x43LIMATE_HOLD_STATUS_ON\x10\x03\x12\x1d\n\x19\x43LIMATE_HOLD_STATUS_FAULT\x10\x04*\x9d\x01\n\x17\x43limateHoldAvailability\x12)\n%CLIMATE_HOLD_AVAILABILITY_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x43LIMATE_HOLD_AVAILABLE\x10\x01\x12\x1d\n\x19\x43LIMATE_HOLD_CONTROLLABLE\x10\x02\x12\x1c\n\x18\x43LIMATE_HOLD_UNAVAILABLE\x10\x03*\xc7\x01\n\x1f\x43limateHoldUnavailabilityReason\x12+\n\'CLIMATE_HOLD_UNAVAILABILITY_UNSPECIFIED\x10\x00\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_UNKNOWN\x10\x01\x12\'\n#CLIMATE_HOLD_UNAVAILABILITY_LOW_SOC\x10\x02\x12%\n!CLIMATE_HOLD_UNAVAILABILITY_FAULT\x10\x03*\x82\x01\n\rDefrostStatus\x12\x1e\n\x1a\x44\x45\x46ROST_STATUS_UNSPECIFIED\x10\x00\x12\x11\n\rDEFROST_DEFOG\x10\x01\x12\x12\n\x0e\x44\x45\x46ROST_ACTIVE\x10\x02\x12\x19\n\x15\x44\x45\x46ROST_DEFOG_DEFROST\x10\x03\x12\x0f\n\x0b\x44\x45\x46ROST_OFF\x10\x04*g\n\x12\x43\x61\x62inSurfaceStatus\x12$\n CABIN_SURFACE_STATUS_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43\x41\x42IN_SURFACE_OFF\x10\x01\x12\x14\n\x10\x43\x41\x42IN_SURFACE_ON\x10\x02*~\n\x13PetModeCabinClimate\x12&\n\"PET_MODE_CABIN_CLIMATE_COMFORTABLE\x10\x00\x12\x1f\n\x1bPET_MODE_CABIN_CLIMATE_COLD\x10\x01\x12\x1e\n\x1aPET_MODE_CABIN_CLIMATE_HOT\x10\x02*]\n\x0cPetModeState\x12\x10\n\x0cPET_MODE_OFF\x10\x00\x12\x0f\n\x0bPET_MODE_ON\x10\x01\x12\x15\n\x11PET_MODE_DISABLED\x10\x02\x12\x13\n\x0fPET_MODE_FAULTY\x10\x03*\x9a\x01\n\x18PetModeTemperatureStatus\x12 \n\x1cPET_MODE_TEMPERATURE_DEFAULT\x10\x00\x12\x1d\n\x19PET_MODE_TEMPERATURE_COLD\x10\x01\x12\x1c\n\x18PET_MODE_TEMPERATURE_HOT\x10\x02\x12\x1f\n\x1bPET_MODE_TEMPERATURE_FAULTY\x10\x03*\xce\x02\n\x0c\x43\x61\x62inSurface\x12\x1d\n\x19\x43\x41\x42IN_SURFACE_UNSPECIFIED\x10\x00\x12\x12\n\x0eSTEERING_WHEEL\x10\x01\x12\x0e\n\nREAR_GLASS\x10\x02\x12\x0f\n\x0b\x46RONT_GLASS\x10\x03\x12\x14\n\x10SIDEVIEW_MIRRORS\x10\x04\x12\x13\n\x0fSEAT_ROW_1_LEFT\x10\x05\x12\x15\n\x11SEAT_ROW_1_MIDDLE\x10\x06\x12\x14\n\x10SEAT_ROW_1_RIGHT\x10\x07\x12\x13\n\x0fSEAT_ROW_2_LEFT\x10\x08\x12\x15\n\x11SEAT_ROW_2_MIDDLE\x10\t\x12\x14\n\x10SEAT_ROW_2_RIGHT\x10\n\x12\x13\n\x0fSEAT_ROW_3_LEFT\x10\x0b\x12\x15\n\x11SEAT_ROW_3_MIDDLE\x10\x0c\x12\x14\n\x10SEAT_ROW_3_RIGHT\x10\r\x12\x0e\n\nWIPER_AREA\x10\x0e*c\n\x10\x43onditioningType\x12!\n\x1d\x43ONDITIONING_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43ONDITIONING_HEAT\x10\x01\x12\x15\n\x11\x43ONDITIONING_VENT\x10\x02*\x85\x01\n\x11\x43onditioningLevel\x12\"\n\x1e\x43ONDITIONING_LEVEL_UNSPECIFIED\x10\x00\x12\x18\n\x14\x43ONDITIONING_LEVEL_1\x10\x01\x12\x18\n\x14\x43ONDITIONING_LEVEL_2\x10\x02\x12\x18\n\x14\x43ONDITIONING_LEVEL_3\x10\x03\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rivian.parallax.proto.comfort_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None - _globals['_PRECONDITIONINGSTATUS']._serialized_start=1850 - _globals['_PRECONDITIONINGSTATUS']._serialized_end=2239 - _globals['_PRECONDITIONINGTYPE']._serialized_start=2242 - _globals['_PRECONDITIONINGTYPE']._serialized_end=2470 - _globals['_ACTION']._serialized_start=2472 - _globals['_ACTION']._serialized_end=2535 - _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_start=2538 - _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_end=2724 - _globals['_CLIMATEHOLDAVAILABILITY']._serialized_start=2727 - _globals['_CLIMATEHOLDAVAILABILITY']._serialized_end=2884 - _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_start=2887 - _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_end=3086 - _globals['_DEFROSTSTATUS']._serialized_start=3089 - _globals['_DEFROSTSTATUS']._serialized_end=3219 - _globals['_PETMODECABINCLIMATE']._serialized_start=3221 - _globals['_PETMODECABINCLIMATE']._serialized_end=3347 - _globals['_PETMODESTATE']._serialized_start=3349 - _globals['_PETMODESTATE']._serialized_end=3442 - _globals['_PETMODETEMPERATURESTATUS']._serialized_start=3445 - _globals['_PETMODETEMPERATURESTATUS']._serialized_end=3599 - _globals['_CABINSURFACE']._serialized_start=3602 - _globals['_CABINSURFACE']._serialized_end=3936 - _globals['_CONDITIONINGTYPE']._serialized_start=3938 - _globals['_CONDITIONINGTYPE']._serialized_end=4037 - _globals['_CONDITIONINGLEVEL']._serialized_start=4040 - _globals['_CONDITIONINGLEVEL']._serialized_end=4173 + _globals['_PRECONDITIONINGSTATUS']._serialized_start=2265 + _globals['_PRECONDITIONINGSTATUS']._serialized_end=2654 + _globals['_PRECONDITIONINGTYPE']._serialized_start=2657 + _globals['_PRECONDITIONINGTYPE']._serialized_end=2885 + _globals['_ACTION']._serialized_start=2887 + _globals['_ACTION']._serialized_end=2950 + _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_start=2953 + _globals['_CLIMATEHOLDSTATUSVALUE']._serialized_end=3139 + _globals['_CLIMATEHOLDAVAILABILITY']._serialized_start=3142 + _globals['_CLIMATEHOLDAVAILABILITY']._serialized_end=3299 + _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_start=3302 + _globals['_CLIMATEHOLDUNAVAILABILITYREASON']._serialized_end=3501 + _globals['_DEFROSTSTATUS']._serialized_start=3504 + _globals['_DEFROSTSTATUS']._serialized_end=3634 + _globals['_CABINSURFACESTATUS']._serialized_start=3636 + _globals['_CABINSURFACESTATUS']._serialized_end=3739 + _globals['_PETMODECABINCLIMATE']._serialized_start=3741 + _globals['_PETMODECABINCLIMATE']._serialized_end=3867 + _globals['_PETMODESTATE']._serialized_start=3869 + _globals['_PETMODESTATE']._serialized_end=3962 + _globals['_PETMODETEMPERATURESTATUS']._serialized_start=3965 + _globals['_PETMODETEMPERATURESTATUS']._serialized_end=4119 + _globals['_CABINSURFACE']._serialized_start=4122 + _globals['_CABINSURFACE']._serialized_end=4456 + _globals['_CONDITIONINGTYPE']._serialized_start=4458 + _globals['_CONDITIONINGTYPE']._serialized_end=4557 + _globals['_CONDITIONINGLEVEL']._serialized_start=4560 + _globals['_CONDITIONINGLEVEL']._serialized_end=4693 _globals['_HVACSETTINGSSTATUS']._serialized_start=64 _globals['_HVACSETTINGSSTATUS']._serialized_end=112 _globals['_USERMODESSTATE']._serialized_start=115 @@ -79,10 +81,16 @@ _globals['_CLIMATEHOLDSTATUS_ENDTIME']._serialized_end=1253 _globals['_DEFROSTDEFOGSTATUS']._serialized_start=1255 _globals['_DEFROSTDEFOGSTATUS']._serialized_end=1331 - _globals['_PETMODESTATUS']._serialized_start=1334 - _globals['_PETMODESTATUS']._serialized_end=1552 - _globals['_SEATCONDITIONINGSTATUS']._serialized_start=1555 - _globals['_SEATCONDITIONINGSTATUS']._serialized_end=1847 - _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_start=1656 - _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_end=1847 + _globals['_DEFROSTDEFOGREQUEST']._serialized_start=1333 + _globals['_DEFROSTDEFOGREQUEST']._serialized_end=1410 + _globals['_PRECONDITIONINGTEMPERATUREREQUEST']._serialized_start=1412 + _globals['_PRECONDITIONINGTEMPERATUREREQUEST']._serialized_end=1489 + _globals['_CABINSURFACEREQUEST']._serialized_start=1492 + _globals['_CABINSURFACEREQUEST']._serialized_end=1746 + _globals['_PETMODESTATUS']._serialized_start=1749 + _globals['_PETMODESTATUS']._serialized_end=1967 + _globals['_SEATCONDITIONINGSTATUS']._serialized_start=1970 + _globals['_SEATCONDITIONINGSTATUS']._serialized_end=2262 + _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_start=2071 + _globals['_SEATCONDITIONINGSTATUS_SURFACE']._serialized_end=2262 # @@protoc_insertion_point(module_scope) diff --git a/src/rivian/parallax/proto/comfort_pb2.pyi b/src/rivian/parallax/proto/comfort_pb2.pyi index 2d24d8d..e2e32a2 100644 --- a/src/rivian/parallax/proto/comfort_pb2.pyi +++ b/src/rivian/parallax/proto/comfort_pb2.pyi @@ -64,6 +64,12 @@ class DefrostStatus(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): DEFROST_DEFOG_DEFROST: _ClassVar[DefrostStatus] DEFROST_OFF: _ClassVar[DefrostStatus] +class CabinSurfaceStatus(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + CABIN_SURFACE_STATUS_UNSPECIFIED: _ClassVar[CabinSurfaceStatus] + CABIN_SURFACE_OFF: _ClassVar[CabinSurfaceStatus] + CABIN_SURFACE_ON: _ClassVar[CabinSurfaceStatus] + class PetModeCabinClimate(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): __slots__ = () PET_MODE_CABIN_CLIMATE_COMFORTABLE: _ClassVar[PetModeCabinClimate] @@ -150,6 +156,9 @@ DEFROST_DEFOG: DefrostStatus DEFROST_ACTIVE: DefrostStatus DEFROST_DEFOG_DEFROST: DefrostStatus DEFROST_OFF: DefrostStatus +CABIN_SURFACE_STATUS_UNSPECIFIED: CabinSurfaceStatus +CABIN_SURFACE_OFF: CabinSurfaceStatus +CABIN_SURFACE_ON: CabinSurfaceStatus PET_MODE_CABIN_CLIMATE_COMFORTABLE: PetModeCabinClimate PET_MODE_CABIN_CLIMATE_COLD: PetModeCabinClimate PET_MODE_CABIN_CLIMATE_HOT: PetModeCabinClimate @@ -276,6 +285,30 @@ class DefrostDefogStatus(_message.Message): status: DefrostStatus def __init__(self, status: _Optional[_Union[DefrostStatus, str]] = ...) -> None: ... +class DefrostDefogRequest(_message.Message): + __slots__ = ("status",) + STATUS_FIELD_NUMBER: _ClassVar[int] + status: DefrostStatus + def __init__(self, status: _Optional[_Union[DefrostStatus, str]] = ...) -> None: ... + +class PreconditioningTemperatureRequest(_message.Message): + __slots__ = ("temperature",) + TEMPERATURE_FIELD_NUMBER: _ClassVar[int] + temperature: float + def __init__(self, temperature: _Optional[float] = ...) -> None: ... + +class CabinSurfaceRequest(_message.Message): + __slots__ = ("surface", "level", "status", "type") + SURFACE_FIELD_NUMBER: _ClassVar[int] + LEVEL_FIELD_NUMBER: _ClassVar[int] + STATUS_FIELD_NUMBER: _ClassVar[int] + TYPE_FIELD_NUMBER: _ClassVar[int] + surface: CabinSurface + level: ConditioningLevel + status: CabinSurfaceStatus + type: ConditioningType + def __init__(self, surface: _Optional[_Union[CabinSurface, str]] = ..., level: _Optional[_Union[ConditioningLevel, str]] = ..., status: _Optional[_Union[CabinSurfaceStatus, str]] = ..., type: _Optional[_Union[ConditioningType, str]] = ...) -> None: ... + class PetModeStatus(_message.Message): __slots__ = ("status", "temperature_status", "cabin_climate") STATUS_FIELD_NUMBER: _ClassVar[int] diff --git a/src/rivian/parallax/vehicle_command.py b/src/rivian/parallax/vehicle_command.py new file mode 100644 index 0000000..957dfa7 --- /dev/null +++ b/src/rivian/parallax/vehicle_command.py @@ -0,0 +1,236 @@ +"""Parallax equivalents of `VehicleCommand`s. + +The Rivian app sends a command over Parallax when the vehicle reports the +supported feature for the command's category as AVAILABLE, and as a legacy +`sendVehicleCommand` otherwise. +""" + +from __future__ import annotations + +from collections.abc import Callable +from typing import Any + +from ..const import VehicleCommand +from ..exceptions import RivianBadRequestError +from .body import LOCK_RVM, UNLOCK_RVM, encode_unlock +from .proto import body_pb2, charging_pb2, comfort_pb2 + +_Build = Callable[[dict[str, Any]], bytes] + +_BODY = "PVS_BD_CMD" +_LIFTGATE = "LIFTGATE_CMD" +_COMFORT = "PVS_COMF_CMD" +_ENERGY = "PVS_ENRG_CMD" +_SECURITY = "PVS_SEC_CMD" + +_Level = comfort_pb2.ConditioningLevel +_OFF, _LOW, _MEDIUM, _HIGH = ( + comfort_pb2.CONDITIONING_LEVEL_UNSPECIFIED, + comfort_pb2.CONDITIONING_LEVEL_1, + comfort_pb2.CONDITIONING_LEVEL_2, + comfort_pb2.CONDITIONING_LEVEL_3, +) + +_VENT = comfort_pb2.CONDITIONING_VENT + +# Legacy `level` param -> level, as the Rivian app maps them; seats have no "1 = on" +_SEAT_LEVELS: dict[int, _Level] = {0: _OFF, 2: _LOW, 3: _MEDIUM, 4: _HIGH} +_WHEEL_LEVELS: dict[int, _Level] = {0: _OFF, 1: _LOW, 2: _MEDIUM, 3: _HIGH} + + +def _empty(params: dict[str, Any]) -> bytes: + return b"" + + +def _closure(closure: body_pb2.ClosureId) -> _Build: + def build(params: dict[str, Any]) -> bytes: + return body_pb2.ClosuresRequest(closures=[closure]).SerializeToString() + + return build + + +def _unlock(params: dict[str, Any]) -> bytes: + return encode_unlock() + + +def _surface( + surface: comfort_pb2.CabinSurface, + type_: comfort_pb2.ConditioningType, + levels: dict[int, _Level], +) -> _Build: + def build(params: dict[str, Any]) -> bytes: + if (level := levels.get(params.get("level", -1))) is None: + raise RivianBadRequestError(f"Level must be one of {list(levels)}") + return comfort_pb2.CabinSurfaceRequest( + surface=surface, + level=level, + status=comfort_pb2.CABIN_SURFACE_ON + if level + else comfort_pb2.CABIN_SURFACE_OFF, + type=type_, + ).SerializeToString() + + return build + + +def _defrost(params: dict[str, Any]) -> bytes: + status = ( + comfort_pb2.DEFROST_DEFOG_DEFROST + if params.get("level") + else comfort_pb2.DEFROST_OFF + ) + return comfort_pb2.DefrostDefogRequest(status=status).SerializeToString() + + +def _temperature(params: dict[str, Any]) -> bytes: + temp = params.get("HVAC_set_temp") + if not (isinstance(temp, (int, float)) and (16 <= temp <= 29 or temp in (0, 63.5))): + raise RivianBadRequestError( + "Temperature must be between 16 and 29 or 0/63.5 for LO/HI" + ) + return comfort_pb2.PreconditioningTemperatureRequest( + temperature=temp + ).SerializeToString() + + +def _charge_limit(params: dict[str, Any]) -> bytes: + limit = params.get("SOC_limit") + if not (isinstance(limit, int) and 50 <= limit <= 100): + raise RivianBadRequestError("Charging limit must be between 50 and 100") + return charging_pb2.ChargeLimitRequest(limit=limit).SerializeToString() + + +def _seat( + surface: comfort_pb2.CabinSurface, + type_: comfort_pb2.ConditioningType = comfort_pb2.CONDITIONING_HEAT, +) -> tuple[str, str, _Build]: + return ( + _COMFORT, + "comfort.cabin.set_cabin_surface", + _surface(surface, type_, _SEAT_LEVELS), + ) + + +_COMMANDS: dict[str, tuple[str, str, _Build]] = { + VehicleCommand.LOCK_ALL_CLOSURES_FEEDBACK: (_BODY, LOCK_RVM, _empty), + VehicleCommand.UNLOCK_ALL_CLOSURES: (_BODY, UNLOCK_RVM, _unlock), + VehicleCommand.OPEN_ALL_WINDOWS: ( + _BODY, + "body.closures.open", + _closure(body_pb2.GROUP_WINDOWS), + ), + VehicleCommand.CLOSE_ALL_WINDOWS: ( + _BODY, + "body.closures.close", + _closure(body_pb2.GROUP_WINDOWS), + ), + VehicleCommand.OPEN_FRUNK: (_BODY, "body.closures.open", _closure(body_pb2.FRUNK)), + VehicleCommand.CLOSE_FRUNK: ( + _BODY, + "body.closures.close", + _closure(body_pb2.FRUNK), + ), + # Vehicles without LIFTGATE_CMD, e.g. an R1T's tailgate, keep the old command + VehicleCommand.OPEN_LIFTGATE_UNLATCH_TAILGATE: ( + _LIFTGATE, + "body.closures.open", + _closure(body_pb2.LIFTGATE), + ), + VehicleCommand.CLOSE_LIFTGATE: ( + _LIFTGATE, + "body.closures.close", + _closure(body_pb2.LIFTGATE), + ), + VehicleCommand.OPEN_CHARGE_PORT_DOOR: ( + _BODY, + "body.closures.open", + _closure(body_pb2.CHARGE_PORT), + ), + VehicleCommand.CLOSE_CHARGE_PORT_DOOR: ( + _BODY, + "body.closures.close", + _closure(body_pb2.CHARGE_PORT), + ), + VehicleCommand.PANIC_ON: (_SECURITY, "security.alarm.enable_panic", _empty), + VehicleCommand.PANIC_OFF: (_SECURITY, "security.alarm.disable_panic", _empty), + VehicleCommand.ENABLE_GEAR_GUARD_VIDEO: ( + _SECURITY, + "security.video_monitoring.enable_video_monitoring", + _empty, + ), + VehicleCommand.DISABLE_GEAR_GUARD_VIDEO: ( + _SECURITY, + "security.video_monitoring.disable_video_monitoring", + _empty, + ), + VehicleCommand.VEHICLE_CABIN_PRECONDITION_ENABLE: ( + _COMFORT, + "comfort.cabin.enable_preconditioning", + _empty, + ), + VehicleCommand.VEHICLE_CABIN_PRECONDITION_DISABLE: ( + _COMFORT, + "comfort.cabin.disable_preconditioning", + _empty, + ), + VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP: ( + _COMFORT, + "comfort.cabin.set_preconditioning_temperature", + _temperature, + ), + VehicleCommand.CABIN_HVAC_DEFROST_DEFOG: ( + _COMFORT, + "comfort.cabin.set_defrost_defog", + _defrost, + ), + VehicleCommand.CABIN_HVAC_LEFT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_1_LEFT), + VehicleCommand.CABIN_HVAC_RIGHT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_1_RIGHT), + VehicleCommand.CABIN_HVAC_LEFT_SEAT_VENT: _seat(comfort_pb2.SEAT_ROW_1_LEFT, _VENT), + VehicleCommand.CABIN_HVAC_RIGHT_SEAT_VENT: _seat( + comfort_pb2.SEAT_ROW_1_RIGHT, _VENT + ), + VehicleCommand.CABIN_HVAC_REAR_LEFT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_2_LEFT), + VehicleCommand.CABIN_HVAC_REAR_RIGHT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_2_RIGHT), + VehicleCommand.CABIN_HVAC_3RD_ROW_REAR_LEFT_SEAT_HEAT: _seat( + comfort_pb2.SEAT_ROW_3_LEFT + ), + VehicleCommand.CABIN_HVAC_3RD_ROW_REAR_RIGHT_SEAT_HEAT: _seat( + comfort_pb2.SEAT_ROW_3_RIGHT + ), + VehicleCommand.CABIN_HVAC_STEERING_HEAT: ( + _COMFORT, + "comfort.cabin.set_cabin_surface", + _surface( + comfort_pb2.STEERING_WHEEL, comfort_pb2.CONDITIONING_HEAT, _WHEEL_LEVELS + ), + ), + VehicleCommand.START_CHARGING: (_ENERGY, "charging.energy.start_charging", _empty), + VehicleCommand.STOP_CHARGING: (_ENERGY, "charging.energy.stop_charging", _empty), + VehicleCommand.CHARGING_LIMITS: ( + _ENERGY, + "charging.energy.set_charge_limit", + _charge_limit, + ), +} + + +def vehicle_command_feature(command: VehicleCommand | str) -> str | None: + """Return the supported feature that sends a command over Parallax. + + None if the command has no Parallax equivalent, e.g. honk or wake. + """ + return entry[0] if (entry := _COMMANDS.get(command)) else None + + +def encode_vehicle_command( + command: VehicleCommand | str, + params: dict[str, Any] | None = None, +) -> tuple[str, bytes]: + """Return the RVM and payload for a command's Parallax equivalent. + + `params` are those of `send_vehicle_command`. + """ + if not (entry := _COMMANDS.get(command)): + raise RivianBadRequestError(f"{command} has no Parallax equivalent") + _, rvm, build = entry + return rvm, build(params or {}) diff --git a/tests/parallax/test_vehicle_command.py b/tests/parallax/test_vehicle_command.py new file mode 100644 index 0000000..9fca893 --- /dev/null +++ b/tests/parallax/test_vehicle_command.py @@ -0,0 +1,127 @@ +"""Tests for the Parallax equivalents of vehicle commands.""" + +from __future__ import annotations + +from typing import Any + +import pytest + +from rivian import VehicleCommand +from rivian.exceptions import RivianBadRequestError +from rivian.parallax import encode_vehicle_command, vehicle_command_feature + + +@pytest.mark.parametrize( + ("command", "params", "rvm", "payload"), + [ + (VehicleCommand.LOCK_ALL_CLOSURES_FEEDBACK, None, "body.locks.lock", b""), + ( + VehicleCommand.UNLOCK_ALL_CLOSURES, + None, + "body.locks.unlock", + b"\x08\x01", + ), + ( + VehicleCommand.OPEN_ALL_WINDOWS, + None, + "body.closures.open", + b"\x0a\x02\x90\x4e", + ), + ( + VehicleCommand.CLOSE_FRUNK, + None, + "body.closures.close", + b"\x0a\x01\x05", + ), + ( + VehicleCommand.OPEN_LIFTGATE_UNLATCH_TAILGATE, + None, + "body.closures.open", + b"\x0a\x01\x07", + ), + (VehicleCommand.PANIC_ON, None, "security.alarm.enable_panic", b""), + ( + VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, + {"HVAC_set_temp": 21.0}, + "comfort.cabin.set_preconditioning_temperature", + b"\x0d\x00\x00\xa8\x41", + ), + ( + VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, + {"HVAC_set_temp": 0}, + "comfort.cabin.set_preconditioning_temperature", + b"\x0d\x00\x00\x00\x00", + ), + ( + VehicleCommand.CABIN_HVAC_LEFT_SEAT_HEAT, + {"level": 2}, + "comfort.cabin.set_cabin_surface", + b"\x08\x05\x10\x01\x18\x02\x20\x01", + ), + ( + VehicleCommand.CABIN_HVAC_STEERING_HEAT, + {"level": 0}, + "comfort.cabin.set_cabin_surface", + b"\x08\x01\x18\x01\x20\x01", + ), + ( + VehicleCommand.CABIN_HVAC_DEFROST_DEFOG, + {"level": 1}, + "comfort.cabin.set_defrost_defog", + b"\x08\x03", + ), + ( + VehicleCommand.CABIN_HVAC_DEFROST_DEFOG, + {"level": 0}, + "comfort.cabin.set_defrost_defog", + b"\x08\x04", + ), + ( + VehicleCommand.CHARGING_LIMITS, + {"SOC_limit": 80}, + "charging.energy.set_charge_limit", + b"\x08\x50", + ), + ], +) +def test_encode( + command: VehicleCommand, + params: dict[str, Any] | None, + rvm: str, + payload: bytes, +) -> None: + """Commands encode like the Rivian app's.""" + assert encode_vehicle_command(command, params) == (rvm, payload) + + +def test_feature() -> None: + """Each command is sent over Parallax per its category's feature.""" + assert vehicle_command_feature(VehicleCommand.UNLOCK_ALL_CLOSURES) == "PVS_BD_CMD" + assert vehicle_command_feature(VehicleCommand.PANIC_OFF) == "PVS_SEC_CMD" + assert ( + vehicle_command_feature(VehicleCommand.CABIN_HVAC_LEFT_SEAT_VENT) + == "PVS_COMF_CMD" + ) + assert vehicle_command_feature(VehicleCommand.START_CHARGING) == "PVS_ENRG_CMD" + assert vehicle_command_feature(VehicleCommand.CLOSE_LIFTGATE) == "LIFTGATE_CMD" + assert vehicle_command_feature(VehicleCommand.WAKE_VEHICLE) is None + assert vehicle_command_feature("NOT_A_COMMAND") is None + + +@pytest.mark.parametrize( + ("command", "params"), + [ + (VehicleCommand.WAKE_VEHICLE, None), + (VehicleCommand.CABIN_HVAC_LEFT_SEAT_HEAT, {"level": 1}), + (VehicleCommand.CABIN_HVAC_STEERING_HEAT, {"level": 4}), + (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": 30}), + (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 40}), + (VehicleCommand.CHARGING_LIMITS, None), + (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 80.5}), + (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": "warm"}), + ], +) +def test_invalid(command: VehicleCommand, params: dict[str, Any] | None) -> None: + """Commands without an equivalent, or with invalid params, are rejected.""" + with pytest.raises(RivianBadRequestError): + encode_vehicle_command(command, params) From 783b4e6ef3fa515975fedaf14cc2d6b0a3b2f026 Mon Sep 17 00:00:00 2001 From: Walt Howd Date: Sun, 15 Nov 2026 21:17:29 +0000 Subject: [PATCH 8/8] Gate the liftgate on PVS_BD_CMD and follow the parallax layout - 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. --- src/rivian/parallax/__init__.py | 52 ++++- src/rivian/parallax/body.py | 7 + src/rivian/parallax/charging.py | 10 + src/rivian/parallax/comfort.py | 34 +++ src/rivian/parallax/proto/comfort.proto | 2 +- src/rivian/parallax/security.py | 6 + src/rivian/parallax/vehicle_command.py | 285 +++++++++++------------- src/rivian/rivian.py | 33 +-- tests/parallax/test_vehicle_command.py | 12 +- tests/test_rivian.py | 28 +++ 10 files changed, 296 insertions(+), 173 deletions(-) diff --git a/src/rivian/parallax/__init__.py b/src/rivian/parallax/__init__.py index 1e2f53d..179c169 100644 --- a/src/rivian/parallax/__init__.py +++ b/src/rivian/parallax/__init__.py @@ -24,6 +24,11 @@ encode_climate_hold(on), encode_pet_mode(on) -> bytes Payloads for the signed SET_CLIMATE_HOLD_RVM and SET_PET_MODE_RVM commands. + encode_closures(closure), encode_cabin_surface(surface, conditioning, level), + encode_defrost_defog(on), encode_preconditioning_temperature(celsius), + encode_charge_limit(percent) -> bytes + Payloads for signed body, comfort and charging commands; each command's + RVM is a `*_RVM` constant. vehicle_command_feature(command) -> str | None The supported feature that, when AVAILABLE, sends a `VehicleCommand` over Parallax. @@ -64,15 +69,37 @@ vehicle, vehicle_access, ) -from .body import LOCK_RVM, UNLOCK_RVM, encode_lock, encode_unlock +from .body import ( + CLOSE_CLOSURES_RVM, + LOCK_RVM, + OPEN_CLOSURES_RVM, + UNLOCK_RVM, + encode_closures, + encode_lock, + encode_unlock, +) +from .charging import ( + SET_CHARGE_LIMIT_RVM, + START_CHARGING_RVM, + STOP_CHARGING_RVM, + encode_charge_limit, +) from .comfort import ( CLIMATE_HOLD_SETTING_RVM, CLIMATE_HOLD_STATUS_RVM, + DISABLE_PRECONDITIONING_RVM, + ENABLE_PRECONDITIONING_RVM, + SET_CABIN_SURFACE_RVM, SET_CLIMATE_HOLD_RVM, + SET_DEFROST_DEFOG_RVM, SET_PET_MODE_RVM, + SET_PRECONDITIONING_TEMPERATURE_RVM, + encode_cabin_surface, encode_climate_hold, encode_climate_hold_setting, + encode_defrost_defog, encode_pet_mode, + encode_preconditioning_temperature, ) from .command import decode_command_state_message, encode_command from .core import ( @@ -83,6 +110,10 @@ from .navigation import UPDATED_TRIP_MODEL, encode_end_trip from .operation import encode_vehicle_operation from .security import ( + DISABLE_PANIC_RVM, + DISABLE_VIDEO_MONITORING_RVM, + ENABLE_PANIC_RVM, + ENABLE_VIDEO_MONITORING_RVM, GEAR_GUARD_CAMERAS, START_LIVE_STREAMING_RVM, encode_live_streaming, @@ -108,24 +139,43 @@ "CHARGING_RVMS", "CLIMATE_HOLD_SETTING_RVM", "CLIMATE_HOLD_STATUS_RVM", + "CLOSE_CLOSURES_RVM", + "DISABLE_PANIC_RVM", + "DISABLE_PRECONDITIONING_RVM", + "DISABLE_VIDEO_MONITORING_RVM", + "ENABLE_PANIC_RVM", + "ENABLE_PRECONDITIONING_RVM", + "ENABLE_VIDEO_MONITORING_RVM", "GEAR_GUARD_CAMERAS", "LOCK_RVM", + "OPEN_CLOSURES_RVM", "PARALLAX_RVMS", + "SET_CABIN_SURFACE_RVM", + "SET_CHARGE_LIMIT_RVM", "SET_CLIMATE_HOLD_RVM", + "SET_DEFROST_DEFOG_RVM", "SET_PET_MODE_RVM", + "SET_PRECONDITIONING_TEMPERATURE_RVM", + "START_CHARGING_RVM", "START_LIVE_STREAMING_RVM", + "STOP_CHARGING_RVM", "UNLOCK_RVM", "UPDATED_TRIP_MODEL", "decode_command_state_message", "decode_parallax_message", "decode_parallax_subscription_message", + "encode_cabin_surface", + "encode_charge_limit", "encode_climate_hold", "encode_climate_hold_setting", + "encode_closures", "encode_command", + "encode_defrost_defog", "encode_end_trip", "encode_live_streaming", "encode_lock", "encode_pet_mode", + "encode_preconditioning_temperature", "encode_unlock", "encode_vehicle_command", "encode_vehicle_operation", diff --git a/src/rivian/parallax/body.py b/src/rivian/parallax/body.py index 6107bd1..97992bb 100644 --- a/src/rivian/parallax/body.py +++ b/src/rivian/parallax/body.py @@ -9,6 +9,8 @@ LOCK_RVM: Final = "body.locks.lock" UNLOCK_RVM: Final = "body.locks.unlock" +OPEN_CLOSURES_RVM: Final = "body.closures.open" +CLOSE_CLOSURES_RVM: Final = "body.closures.close" _CLOSURE_MAP: Final[dict[int, str]] = { body_pb2.DOOR_FRONT_LEFT: "doorFrontLeftClosed", @@ -186,6 +188,11 @@ def encode_unlock() -> bytes: return body_pb2.UnlockCommand(all=True).SerializeToString() +def encode_closures(closure: body_pb2.ClosureId) -> bytes: + """Encode a body.closures.open or body.closures.close payload.""" + return body_pb2.ClosuresRequest(closures=[closure]).SerializeToString() + + @RVMDecoder.register("body.locks.states", body_pb2.LocksState) def decode_locks(m: body_pb2.LocksState) -> dict[str, Any]: """body.locks.states — lock state of every lock. diff --git a/src/rivian/parallax/charging.py b/src/rivian/parallax/charging.py index 4c41a3a..a311632 100644 --- a/src/rivian/parallax/charging.py +++ b/src/rivian/parallax/charging.py @@ -8,6 +8,16 @@ from .core import RVMDecoder, _enum, _present from .proto import charging_pb2 +START_CHARGING_RVM: Final = "charging.energy.start_charging" +STOP_CHARGING_RVM: Final = "charging.energy.stop_charging" +SET_CHARGE_LIMIT_RVM: Final = "charging.energy.set_charge_limit" + + +def encode_charge_limit(percent: int) -> bytes: + """Encode a charging.energy.set_charge_limit payload.""" + return charging_pb2.ChargeLimitRequest(limit=percent).SerializeToString() + + _DAY_OF_WEEK_MAP: Final[dict[int, str]] = { charging_pb2.ScheduleTimeWindow.SUNDAY: "sunday", charging_pb2.ScheduleTimeWindow.MONDAY: "monday", diff --git a/src/rivian/parallax/comfort.py b/src/rivian/parallax/comfort.py index da6f64f..3378bef 100644 --- a/src/rivian/parallax/comfort.py +++ b/src/rivian/parallax/comfort.py @@ -11,6 +11,13 @@ CLIMATE_HOLD_STATUS_RVM: Final = "comfort.cabin.climate_hold_status" SET_CLIMATE_HOLD_RVM: Final = "comfort.cabin.set_climate_hold" SET_PET_MODE_RVM: Final = "comfort.cabin.set_pet_mode" +ENABLE_PRECONDITIONING_RVM: Final = "comfort.cabin.enable_preconditioning" +DISABLE_PRECONDITIONING_RVM: Final = "comfort.cabin.disable_preconditioning" +SET_PRECONDITIONING_TEMPERATURE_RVM: Final = ( + "comfort.cabin.set_preconditioning_temperature" +) +SET_DEFROST_DEFOG_RVM: Final = "comfort.cabin.set_defrost_defog" +SET_CABIN_SURFACE_RVM: Final = "comfort.cabin.set_cabin_surface" @RVMDecoder.register( @@ -222,6 +229,33 @@ def encode_pet_mode(on: bool) -> bytes: return comfort_pb2.ActionRequest(action=action).SerializeToString() +def encode_preconditioning_temperature(celsius: float) -> bytes: + """Encode a comfort.cabin.set_preconditioning_temperature payload.""" + return comfort_pb2.PreconditioningTemperatureRequest( + temperature=celsius + ).SerializeToString() + + +def encode_defrost_defog(on: bool) -> bytes: + """Encode a comfort.cabin.set_defrost_defog payload.""" + status = comfort_pb2.DEFROST_DEFOG_DEFROST if on else comfort_pb2.DEFROST_OFF + return comfort_pb2.DefrostDefogRequest(status=status).SerializeToString() + + +def encode_cabin_surface( + surface: comfort_pb2.CabinSurface, + conditioning: comfort_pb2.ConditioningType, + level: comfort_pb2.ConditioningLevel, +) -> bytes: + """Encode a comfort.cabin.set_cabin_surface payload; level 0 turns it off.""" + return comfort_pb2.CabinSurfaceRequest( + surface=surface, + level=level, + status=comfort_pb2.CABIN_SURFACE_ON if level else comfort_pb2.CABIN_SURFACE_OFF, + type=conditioning, + ).SerializeToString() + + @RVMDecoder.register(CLIMATE_HOLD_SETTING_RVM, comfort_pb2.ClimateHoldSetting) def decode_climate_hold_setting(m: comfort_pb2.ClimateHoldSetting) -> dict[str, Any]: """comfort.cabin.climate_hold_setting — configured climate-hold duration. diff --git a/src/rivian/parallax/proto/comfort.proto b/src/rivian/parallax/proto/comfort.proto index 8eb341a..fb59a9b 100644 --- a/src/rivian/parallax/proto/comfort.proto +++ b/src/rivian/parallax/proto/comfort.proto @@ -140,7 +140,7 @@ message DefrostDefogRequest { // comfort.cabin.set_preconditioning_temperature message PreconditioningTemperatureRequest { - optional float temperature = 1; // °C; sent even for 0 (LO) + optional float temperature = 1; // °C; the app sends LO (0) as an empty payload, and the vehicle reads both as 0 } enum CabinSurfaceStatus { diff --git a/src/rivian/parallax/security.py b/src/rivian/parallax/security.py index c0f40fb..bf67634 100644 --- a/src/rivian/parallax/security.py +++ b/src/rivian/parallax/security.py @@ -8,6 +8,12 @@ from .proto import security_pb2 START_LIVE_STREAMING_RVM: Final = "security.video_monitoring.start_live_streaming" +ENABLE_PANIC_RVM: Final = "security.alarm.enable_panic" +DISABLE_PANIC_RVM: Final = "security.alarm.disable_panic" +ENABLE_VIDEO_MONITORING_RVM: Final = "security.video_monitoring.enable_video_monitoring" +DISABLE_VIDEO_MONITORING_RVM: Final = ( + "security.video_monitoring.disable_video_monitoring" +) GEAR_GUARD_CAMERAS: Final[dict[str, security_pb2.GearGuardCamera]] = { "front": security_pb2.GEAR_GUARD_CAMERA_FRONT, diff --git a/src/rivian/parallax/vehicle_command.py b/src/rivian/parallax/vehicle_command.py index 957dfa7..dd8f862 100644 --- a/src/rivian/parallax/vehicle_command.py +++ b/src/rivian/parallax/vehicle_command.py @@ -1,193 +1,169 @@ """Parallax equivalents of `VehicleCommand`s. -The Rivian app sends a command over Parallax when the vehicle reports the -supported feature for the command's category as AVAILABLE, and as a legacy +The Rivian app sends a command over Parallax when the vehicle reports its +category's supported feature as AVAILABLE, and as a legacy `sendVehicleCommand` otherwise. """ from __future__ import annotations from collections.abc import Callable -from typing import Any +from typing import Any, Final from ..const import VehicleCommand from ..exceptions import RivianBadRequestError -from .body import LOCK_RVM, UNLOCK_RVM, encode_unlock -from .proto import body_pb2, charging_pb2, comfort_pb2 - -_Build = Callable[[dict[str, Any]], bytes] - -_BODY = "PVS_BD_CMD" -_LIFTGATE = "LIFTGATE_CMD" -_COMFORT = "PVS_COMF_CMD" -_ENERGY = "PVS_ENRG_CMD" -_SECURITY = "PVS_SEC_CMD" - -_Level = comfort_pb2.ConditioningLevel -_OFF, _LOW, _MEDIUM, _HIGH = ( - comfort_pb2.CONDITIONING_LEVEL_UNSPECIFIED, - comfort_pb2.CONDITIONING_LEVEL_1, - comfort_pb2.CONDITIONING_LEVEL_2, - comfort_pb2.CONDITIONING_LEVEL_3, +from .body import ( + CLOSE_CLOSURES_RVM, + LOCK_RVM, + OPEN_CLOSURES_RVM, + UNLOCK_RVM, + encode_closures, + encode_lock, + encode_unlock, +) +from .charging import ( + SET_CHARGE_LIMIT_RVM, + START_CHARGING_RVM, + STOP_CHARGING_RVM, + encode_charge_limit, +) +from .comfort import ( + DISABLE_PRECONDITIONING_RVM, + ENABLE_PRECONDITIONING_RVM, + SET_CABIN_SURFACE_RVM, + SET_DEFROST_DEFOG_RVM, + SET_PRECONDITIONING_TEMPERATURE_RVM, + encode_cabin_surface, + encode_defrost_defog, + encode_preconditioning_temperature, +) +from .proto import body_pb2, comfort_pb2 +from .security import ( + DISABLE_PANIC_RVM, + DISABLE_VIDEO_MONITORING_RVM, + ENABLE_PANIC_RVM, + ENABLE_VIDEO_MONITORING_RVM, ) - -_VENT = comfort_pb2.CONDITIONING_VENT # Legacy `level` param -> level, as the Rivian app maps them; seats have no "1 = on" -_SEAT_LEVELS: dict[int, _Level] = {0: _OFF, 2: _LOW, 3: _MEDIUM, 4: _HIGH} -_WHEEL_LEVELS: dict[int, _Level] = {0: _OFF, 1: _LOW, 2: _MEDIUM, 3: _HIGH} - - -def _empty(params: dict[str, Any]) -> bytes: - return b"" - - -def _closure(closure: body_pb2.ClosureId) -> _Build: - def build(params: dict[str, Any]) -> bytes: - return body_pb2.ClosuresRequest(closures=[closure]).SerializeToString() - - return build - - -def _unlock(params: dict[str, Any]) -> bytes: - return encode_unlock() - - -def _surface( - surface: comfort_pb2.CabinSurface, - type_: comfort_pb2.ConditioningType, - levels: dict[int, _Level], -) -> _Build: - def build(params: dict[str, Any]) -> bytes: - if (level := levels.get(params.get("level", -1))) is None: - raise RivianBadRequestError(f"Level must be one of {list(levels)}") - return comfort_pb2.CabinSurfaceRequest( - surface=surface, - level=level, - status=comfort_pb2.CABIN_SURFACE_ON - if level - else comfort_pb2.CABIN_SURFACE_OFF, - type=type_, - ).SerializeToString() - - return build - - -def _defrost(params: dict[str, Any]) -> bytes: - status = ( - comfort_pb2.DEFROST_DEFOG_DEFROST - if params.get("level") - else comfort_pb2.DEFROST_OFF - ) - return comfort_pb2.DefrostDefogRequest(status=status).SerializeToString() - - -def _temperature(params: dict[str, Any]) -> bytes: - temp = params.get("HVAC_set_temp") - if not (isinstance(temp, (int, float)) and (16 <= temp <= 29 or temp in (0, 63.5))): - raise RivianBadRequestError( - "Temperature must be between 16 and 29 or 0/63.5 for LO/HI" - ) - return comfort_pb2.PreconditioningTemperatureRequest( - temperature=temp - ).SerializeToString() - +_SEAT_LEVELS: Final[dict[int, comfort_pb2.ConditioningLevel]] = { + 0: comfort_pb2.CONDITIONING_LEVEL_UNSPECIFIED, + 2: comfort_pb2.CONDITIONING_LEVEL_1, + 3: comfort_pb2.CONDITIONING_LEVEL_2, + 4: comfort_pb2.CONDITIONING_LEVEL_3, +} +_STEERING_WHEEL_LEVELS: Final[dict[int, comfort_pb2.ConditioningLevel]] = { + 0: comfort_pb2.CONDITIONING_LEVEL_UNSPECIFIED, + 1: comfort_pb2.CONDITIONING_LEVEL_1, + 2: comfort_pb2.CONDITIONING_LEVEL_2, + 3: comfort_pb2.CONDITIONING_LEVEL_3, +} -def _charge_limit(params: dict[str, Any]) -> bytes: - limit = params.get("SOC_limit") - if not (isinstance(limit, int) and 50 <= limit <= 100): - raise RivianBadRequestError("Charging limit must be between 50 and 100") - return charging_pb2.ChargeLimitRequest(limit=limit).SerializeToString() +_Encode = Callable[[dict[str, Any]], bytes] def _seat( surface: comfort_pb2.CabinSurface, - type_: comfort_pb2.ConditioningType = comfort_pb2.CONDITIONING_HEAT, -) -> tuple[str, str, _Build]: + conditioning: comfort_pb2.ConditioningType = comfort_pb2.CONDITIONING_HEAT, +) -> tuple[str, str, _Encode]: return ( - _COMFORT, - "comfort.cabin.set_cabin_surface", - _surface(surface, type_, _SEAT_LEVELS), + "PVS_COMF_CMD", + SET_CABIN_SURFACE_RVM, + lambda p: encode_cabin_surface(surface, conditioning, _SEAT_LEVELS[p["level"]]), ) -_COMMANDS: dict[str, tuple[str, str, _Build]] = { - VehicleCommand.LOCK_ALL_CLOSURES_FEEDBACK: (_BODY, LOCK_RVM, _empty), - VehicleCommand.UNLOCK_ALL_CLOSURES: (_BODY, UNLOCK_RVM, _unlock), +# Command -> (supported feature, RVM, encoder of the `send_vehicle_command` params) +_COMMANDS: Final[dict[str, tuple[str, str, _Encode]]] = { + VehicleCommand.LOCK_ALL_CLOSURES_FEEDBACK: ( + "PVS_BD_CMD", + LOCK_RVM, + lambda _: encode_lock(), + ), + VehicleCommand.UNLOCK_ALL_CLOSURES: ( + "PVS_BD_CMD", + UNLOCK_RVM, + lambda _: encode_unlock(), + ), VehicleCommand.OPEN_ALL_WINDOWS: ( - _BODY, - "body.closures.open", - _closure(body_pb2.GROUP_WINDOWS), + "PVS_BD_CMD", + OPEN_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.GROUP_WINDOWS), ), VehicleCommand.CLOSE_ALL_WINDOWS: ( - _BODY, - "body.closures.close", - _closure(body_pb2.GROUP_WINDOWS), + "PVS_BD_CMD", + CLOSE_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.GROUP_WINDOWS), + ), + VehicleCommand.OPEN_FRUNK: ( + "PVS_BD_CMD", + OPEN_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.FRUNK), ), - VehicleCommand.OPEN_FRUNK: (_BODY, "body.closures.open", _closure(body_pb2.FRUNK)), VehicleCommand.CLOSE_FRUNK: ( - _BODY, - "body.closures.close", - _closure(body_pb2.FRUNK), + "PVS_BD_CMD", + CLOSE_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.FRUNK), ), - # Vehicles without LIFTGATE_CMD, e.g. an R1T's tailgate, keep the old command VehicleCommand.OPEN_LIFTGATE_UNLATCH_TAILGATE: ( - _LIFTGATE, - "body.closures.open", - _closure(body_pb2.LIFTGATE), + "PVS_BD_CMD", + OPEN_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.LIFTGATE), ), VehicleCommand.CLOSE_LIFTGATE: ( - _LIFTGATE, - "body.closures.close", - _closure(body_pb2.LIFTGATE), + "PVS_BD_CMD", + CLOSE_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.LIFTGATE), ), VehicleCommand.OPEN_CHARGE_PORT_DOOR: ( - _BODY, - "body.closures.open", - _closure(body_pb2.CHARGE_PORT), + "PVS_BD_CMD", + OPEN_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.CHARGE_PORT), ), VehicleCommand.CLOSE_CHARGE_PORT_DOOR: ( - _BODY, - "body.closures.close", - _closure(body_pb2.CHARGE_PORT), + "PVS_BD_CMD", + CLOSE_CLOSURES_RVM, + lambda _: encode_closures(body_pb2.CHARGE_PORT), ), - VehicleCommand.PANIC_ON: (_SECURITY, "security.alarm.enable_panic", _empty), - VehicleCommand.PANIC_OFF: (_SECURITY, "security.alarm.disable_panic", _empty), + VehicleCommand.PANIC_ON: ("PVS_SEC_CMD", ENABLE_PANIC_RVM, lambda _: b""), + VehicleCommand.PANIC_OFF: ("PVS_SEC_CMD", DISABLE_PANIC_RVM, lambda _: b""), VehicleCommand.ENABLE_GEAR_GUARD_VIDEO: ( - _SECURITY, - "security.video_monitoring.enable_video_monitoring", - _empty, + "PVS_SEC_CMD", + ENABLE_VIDEO_MONITORING_RVM, + lambda _: b"", ), VehicleCommand.DISABLE_GEAR_GUARD_VIDEO: ( - _SECURITY, - "security.video_monitoring.disable_video_monitoring", - _empty, + "PVS_SEC_CMD", + DISABLE_VIDEO_MONITORING_RVM, + lambda _: b"", ), VehicleCommand.VEHICLE_CABIN_PRECONDITION_ENABLE: ( - _COMFORT, - "comfort.cabin.enable_preconditioning", - _empty, + "PVS_COMF_CMD", + ENABLE_PRECONDITIONING_RVM, + lambda _: b"", ), VehicleCommand.VEHICLE_CABIN_PRECONDITION_DISABLE: ( - _COMFORT, - "comfort.cabin.disable_preconditioning", - _empty, + "PVS_COMF_CMD", + DISABLE_PRECONDITIONING_RVM, + lambda _: b"", ), VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP: ( - _COMFORT, - "comfort.cabin.set_preconditioning_temperature", - _temperature, + "PVS_COMF_CMD", + SET_PRECONDITIONING_TEMPERATURE_RVM, + lambda p: encode_preconditioning_temperature(float(p["HVAC_set_temp"])), ), VehicleCommand.CABIN_HVAC_DEFROST_DEFOG: ( - _COMFORT, - "comfort.cabin.set_defrost_defog", - _defrost, + "PVS_COMF_CMD", + SET_DEFROST_DEFOG_RVM, + lambda p: encode_defrost_defog(bool(p["level"])), ), VehicleCommand.CABIN_HVAC_LEFT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_1_LEFT), VehicleCommand.CABIN_HVAC_RIGHT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_1_RIGHT), - VehicleCommand.CABIN_HVAC_LEFT_SEAT_VENT: _seat(comfort_pb2.SEAT_ROW_1_LEFT, _VENT), + VehicleCommand.CABIN_HVAC_LEFT_SEAT_VENT: _seat( + comfort_pb2.SEAT_ROW_1_LEFT, comfort_pb2.CONDITIONING_VENT + ), VehicleCommand.CABIN_HVAC_RIGHT_SEAT_VENT: _seat( - comfort_pb2.SEAT_ROW_1_RIGHT, _VENT + comfort_pb2.SEAT_ROW_1_RIGHT, comfort_pb2.CONDITIONING_VENT ), VehicleCommand.CABIN_HVAC_REAR_LEFT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_2_LEFT), VehicleCommand.CABIN_HVAC_REAR_RIGHT_SEAT_HEAT: _seat(comfort_pb2.SEAT_ROW_2_RIGHT), @@ -198,18 +174,20 @@ def _seat( comfort_pb2.SEAT_ROW_3_RIGHT ), VehicleCommand.CABIN_HVAC_STEERING_HEAT: ( - _COMFORT, - "comfort.cabin.set_cabin_surface", - _surface( - comfort_pb2.STEERING_WHEEL, comfort_pb2.CONDITIONING_HEAT, _WHEEL_LEVELS + "PVS_COMF_CMD", + SET_CABIN_SURFACE_RVM, + lambda p: encode_cabin_surface( + comfort_pb2.STEERING_WHEEL, + comfort_pb2.CONDITIONING_HEAT, + _STEERING_WHEEL_LEVELS[p["level"]], ), ), - VehicleCommand.START_CHARGING: (_ENERGY, "charging.energy.start_charging", _empty), - VehicleCommand.STOP_CHARGING: (_ENERGY, "charging.energy.stop_charging", _empty), + VehicleCommand.START_CHARGING: ("PVS_ENRG_CMD", START_CHARGING_RVM, lambda _: b""), + VehicleCommand.STOP_CHARGING: ("PVS_ENRG_CMD", STOP_CHARGING_RVM, lambda _: b""), VehicleCommand.CHARGING_LIMITS: ( - _ENERGY, - "charging.energy.set_charge_limit", - _charge_limit, + "PVS_ENRG_CMD", + SET_CHARGE_LIMIT_RVM, + lambda p: encode_charge_limit(p["SOC_limit"]), ), } @@ -228,9 +206,16 @@ def encode_vehicle_command( ) -> tuple[str, bytes]: """Return the RVM and payload for a command's Parallax equivalent. - `params` are those of `send_vehicle_command`. + `params` are those of `send_vehicle_command`, already checked with + `Rivian.validate_vehicle_command`. Seat level 1 and steering wheel level 4 + have no Parallax equivalent. """ if not (entry := _COMMANDS.get(command)): raise RivianBadRequestError(f"{command} has no Parallax equivalent") - _, rvm, build = entry - return rvm, build(params or {}) + _, rvm, encode = entry + try: + return rvm, encode(params or {}) + except KeyError as err: + raise RivianBadRequestError( + f"{command} {params} has no Parallax equivalent" + ) from err diff --git a/src/rivian/rivian.py b/src/rivian/rivian.py index 1501f04..ab4cacc 100644 --- a/src/rivian/rivian.py +++ b/src/rivian/rivian.py @@ -950,10 +950,15 @@ async def get_vehicle_ota_update_details(self, vehicle_id: str) -> ClientRespons return await self.__graphql_query(headers, url, graphql_json) - def _validate_vehicle_command( - self, command: VehicleCommand | str, params: dict[str, Any] | None = None + @staticmethod + def validate_vehicle_command( + command: VehicleCommand | str, params: dict[str, Any] | None = None ) -> None: - """Validate certian vehicle command/param combos.""" + """Raise RivianBadRequestError if a command's params are invalid. + + Shared by `send_vehicle_command` and callers sending its Parallax + equivalent (`parallax.encode_vehicle_command`). + """ if command == VehicleCommand.CHARGING_LIMITS and not ( params and isinstance((limit := params.get("SOC_limit")), int) @@ -981,16 +986,14 @@ def _validate_vehicle_command( raise RivianBadRequestError( "HVAC setting must include parameter `level` with a valid value between 0 and 4" ) - if command == VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP: - if not ( - params - and isinstance((temp := params.get("HVAC_set_temp")), (float, int)) - and (16 <= temp <= 29 or temp in (0, 63.5)) - ): - raise RivianBadRequestError( - "HVAC setting must include parameter `HVAC_set_temp` with a valid value between 16 and 29 or 0/63.5 for LO/HI, respectively" - ) - params["HVAC_set_temp"] = str(params["HVAC_set_temp"]) + if command == VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP and not ( + params + and isinstance((temp := params.get("HVAC_set_temp")), (float, int)) + and (16 <= temp <= 29 or temp in (0, 63.5)) + ): + raise RivianBadRequestError( + "HVAC setting must include parameter `HVAC_set_temp` with a valid value between 16 and 29 or 0/63.5 for LO/HI, respectively" + ) async def send_vehicle_command( self, @@ -1014,7 +1017,9 @@ async def send_vehicle_command( - `CABIN_PRECONDITIONING_SET_TEMP`: params = {"HVAC_set_temp": "deg_C"} where `deg_C` is a string value between 16 and 29 or 0/63.5 for LO/HI, respectively - `CHARGING_LIMITS`: params = {"SOC_limit": 50..100} """ - self._validate_vehicle_command(command, params) + self.validate_vehicle_command(command, params) + if command == VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP and params: + params["HVAC_set_temp"] = str(params["HVAC_set_temp"]) command = str(command) timestamp = str(int(time.time())) diff --git a/tests/parallax/test_vehicle_command.py b/tests/parallax/test_vehicle_command.py index 9fca893..d5cc718 100644 --- a/tests/parallax/test_vehicle_command.py +++ b/tests/parallax/test_vehicle_command.py @@ -103,7 +103,8 @@ def test_feature() -> None: == "PVS_COMF_CMD" ) assert vehicle_command_feature(VehicleCommand.START_CHARGING) == "PVS_ENRG_CMD" - assert vehicle_command_feature(VehicleCommand.CLOSE_LIFTGATE) == "LIFTGATE_CMD" + # Like the app: LIFTGATE_CMD only shows the liftgate controls + assert vehicle_command_feature(VehicleCommand.CLOSE_LIFTGATE) == "PVS_BD_CMD" assert vehicle_command_feature(VehicleCommand.WAKE_VEHICLE) is None assert vehicle_command_feature("NOT_A_COMMAND") is None @@ -114,14 +115,11 @@ def test_feature() -> None: (VehicleCommand.WAKE_VEHICLE, None), (VehicleCommand.CABIN_HVAC_LEFT_SEAT_HEAT, {"level": 1}), (VehicleCommand.CABIN_HVAC_STEERING_HEAT, {"level": 4}), - (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": 30}), - (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 40}), (VehicleCommand.CHARGING_LIMITS, None), - (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 80.5}), - (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": "warm"}), + (VehicleCommand.CABIN_HVAC_DEFROST_DEFOG, {}), ], ) -def test_invalid(command: VehicleCommand, params: dict[str, Any] | None) -> None: - """Commands without an equivalent, or with invalid params, are rejected.""" +def test_no_equivalent(command: VehicleCommand, params: dict[str, Any] | None) -> None: + """Commands, levels or missing params with no Parallax equivalent are rejected.""" with pytest.raises(RivianBadRequestError): encode_vehicle_command(command, params) diff --git a/tests/test_rivian.py b/tests/test_rivian.py index 003e255..7f364ce 100644 --- a/tests/test_rivian.py +++ b/tests/test_rivian.py @@ -931,6 +931,34 @@ async def test_send_vehicle_command_requires_level(command: VehicleCommand) -> N await rivian.close() +@pytest.mark.parametrize( + ("command", "params"), + [ + (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": 30}), + (VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, {"HVAC_set_temp": "warm"}), + (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 40}), + (VehicleCommand.CHARGING_LIMITS, {"SOC_limit": 80.5}), + (VehicleCommand.CHARGING_LIMITS, None), + (VehicleCommand.CABIN_HVAC_STEERING_HEAT, {"level": 5}), + ], +) +def test_validate_vehicle_command( + command: VehicleCommand, params: dict[str, Any] | None +) -> None: + """Invalid params are rejected the same way for either way of sending.""" + with pytest.raises(RivianBadRequestError): + Rivian.validate_vehicle_command(command, params) + + +def test_validate_vehicle_command_keeps_params() -> None: + """Validation leaves the params alone; `send_vehicle_command` converts the temperature.""" + params = {"HVAC_set_temp": 21} + Rivian.validate_vehicle_command( + VehicleCommand.CABIN_PRECONDITIONING_SET_TEMP, params + ) + assert params == {"HVAC_set_temp": 21} + + async def test_graphql_errors(aresponses: ResponsesMockServer) -> None: """Test GraphQL error responses.""" host = "rivian.com"