Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion src/rivian/parallax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
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`.
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.
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
Expand Down Expand Up @@ -54,11 +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 (
Expand All @@ -68,6 +109,16 @@
)
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,
)
from .vehicle_command import encode_vehicle_command, vehicle_command_feature

PARALLAX_RVMS: list[str] = list(RVMDecoder.decoders)

Expand All @@ -88,17 +139,45 @@
"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",
"vehicle_command_feature",
]
7 changes: 7 additions & 0 deletions src/rivian/parallax/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions src/rivian/parallax/charging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 48 additions & 0 deletions src/rivian/parallax/comfort.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

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"
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(
Expand Down Expand Up @@ -208,6 +217,45 @@ 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()


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.
Expand Down
5 changes: 5 additions & 0 deletions src/rivian/parallax/proto/body.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
104 changes: 53 additions & 51 deletions src/rivian/parallax/proto/body_pb2.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/rivian/parallax/proto/body_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/rivian/parallax/proto/charging.proto
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,8 @@ enum ChargerStatus {
message SessionPower {
float power = 1; // kW
}

// charging.energy.set_charge_limit
message ChargeLimitRequest {
uint32 limit = 1; // percent
}
40 changes: 21 additions & 19 deletions src/rivian/parallax/proto/charging_pb2.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/rivian/parallax/proto/charging_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions src/rivian/parallax/proto/comfort.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,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; the app sends LO (0) as an empty payload, and the vehicle reads both as 0
}

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;
Expand Down
Loading
Loading