Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade library #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Binary file added assets/dash-crowd-three.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dash-crowd-two.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dash-crowd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker build -t rivian-logscale .
docker image tag rivian-logscale sween/rivian-logscale:latest
docker push sween/rivian-logscale:latest
31 changes: 20 additions & 11 deletions src/rivian_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def login(self, username, password):
"Dc-Cid": f"m-ios-{uuid.uuid4()}",
}
)
#print(headers)

query = {
"operationName": "Login",
Expand Down Expand Up @@ -128,8 +127,6 @@ def create_csrf_token(self):

def raw_graphql_query(self, url, query, headers):
response = requests.post(url, json=query, headers=headers)
# print(response.status_code)
# print(response.content)
if response.status_code != 200:
log.warning(f"Graphql error: Response status: {response.status_code} Reason: {response.reason}")
return response
Expand Down Expand Up @@ -269,9 +266,6 @@ def get_user_information(self):

def get_vehicle_state(self, vehicle_id, minimal=False):
headers = self.gateway_headers()

query = "query GetVehicleState($vehicleID: String!) { vehicleState(id: $vehicleID) { __typename gnssLocation { __typename latitude longitude timeStamp } alarmSoundStatus { __typename timeStamp value } timeToEndOfCharge { __typename timeStamp value } doorFrontLeftLocked { __typename timeStamp value } doorFrontLeftClosed { __typename timeStamp value } doorFrontRightLocked { __typename timeStamp value } doorFrontRightClosed { __typename timeStamp value } doorRearLeftLocked { __typename timeStamp value } doorRearLeftClosed { __typename timeStamp value } doorRearRightLocked { __typename timeStamp value } doorRearRightClosed { __typename timeStamp value } windowFrontLeftClosed { __typename timeStamp value } windowFrontRightClosed { __typename timeStamp value } windowFrontLeftCalibrated { __typename timeStamp value } windowFrontRightCalibrated { __typename timeStamp value } windowRearLeftCalibrated { __typename timeStamp value } windowRearRightCalibrated { __typename timeStamp value } closureFrunkLocked { __typename timeStamp value } closureFrunkClosed { __typename timeStamp value } gearGuardLocked { __typename timeStamp value } closureLiftgateLocked { __typename timeStamp value } closureLiftgateClosed { __typename timeStamp value } windowRearLeftClosed { __typename timeStamp value } windowRearRightClosed { __typename timeStamp value } closureSideBinLeftLocked { __typename timeStamp value } closureSideBinLeftClosed { __typename timeStamp value } closureSideBinRightLocked { __typename timeStamp value } closureSideBinRightClosed { __typename timeStamp value } closureTailgateLocked { __typename timeStamp value } closureTailgateClosed { __typename timeStamp value } closureTonneauLocked { __typename timeStamp value } closureTonneauClosed { __typename timeStamp value } wiperFluidState { __typename timeStamp value } powerState { __typename timeStamp value } batteryHvThermalEventPropagation { __typename timeStamp value } vehicleMileage { __typename timeStamp value } brakeFluidLow { __typename timeStamp value } gearStatus { __typename timeStamp value } tirePressureStatusFrontLeft { __typename timeStamp value } tirePressureStatusValidFrontLeft { __typename timeStamp value } tirePressureStatusFrontRight { __typename timeStamp value } tirePressureStatusValidFrontRight { __typename timeStamp value } tirePressureStatusRearLeft { __typename timeStamp value } tirePressureStatusValidRearLeft { __typename timeStamp value } tirePressureStatusRearRight { __typename timeStamp value } tirePressureStatusValidRearRight { __typename timeStamp value } batteryLevel { __typename timeStamp value } chargerState { __typename timeStamp value } batteryLimit { __typename timeStamp value } remoteChargingAvailable { __typename timeStamp value } batteryHvThermalEvent { __typename timeStamp value } rangeThreshold { __typename timeStamp value } distanceToEmpty { __typename timeStamp value } otaAvailableVersionNumber { __typename timeStamp value } otaAvailableVersionWeek { __typename timeStamp value } otaAvailableVersionYear { __typename timeStamp value } otaCurrentVersionNumber { __typename timeStamp value } otaCurrentVersionWeek { __typename timeStamp value } otaCurrentVersionYear { __typename timeStamp value } otaDownloadProgress { __typename timeStamp value } otaInstallDuration { __typename timeStamp value } otaInstallProgress { __typename timeStamp value } otaInstallReady { __typename timeStamp value } otaInstallTime { __typename timeStamp value } otaInstallType { __typename timeStamp value } otaStatus { __typename timeStamp value } otaCurrentStatus { __typename timeStamp value } cabinClimateInteriorTemperature { __typename timeStamp value } cabinPreconditioningStatus { __typename timeStamp value } cabinPreconditioningType { __typename timeStamp value } petModeStatus { __typename timeStamp value } petModeTemperatureStatus { __typename timeStamp value } cabinClimateDriverTemperature { __typename timeStamp value } gearGuardVideoStatus { __typename timeStamp value } gearGuardVideoMode { __typename timeStamp value } gearGuardVideoTermsAccepted { __typename timeStamp value } defrostDefogStatus { __typename timeStamp value } steeringWheelHeat { __typename timeStamp value } seatFrontLeftHeat { __typename timeStamp value } seatFrontRightHeat { __typename timeStamp value } seatRearLeftHeat { __typename timeStamp value } seatRearRightHeat { __typename timeStamp value } chargerStatus { __typename timeStamp value } seatFrontLeftVent { __typename timeStamp value } seatFrontRightVent { __typename timeStamp value } chargerDerateStatus { __typename timeStamp value } driveMode { __typename timeStamp value } } }"

if minimal:
query = "query GetVehicleState($vehicleID: String!) { vehicleState(id: $vehicleID) { " \
"cloudConnection { lastSync } " \
Expand All @@ -295,6 +289,8 @@ def get_vehicle_state(self, vehicle_id, minimal=False):
"gnssLocation { __typename latitude longitude timeStamp } " \
"gnssSpeed { __typename timeStamp value } " \
"gnssBearing { __typename timeStamp value } " \
"gnssAltitude { __typename timeStamp value } " \
"gnssError { __typename timeStamp positionVertical positionHorizontal speed bearing } " \
"alarmSoundStatus { __typename timeStamp value } " \
"timeToEndOfCharge { __typename timeStamp value } " \
"doorFrontLeftLocked { __typename timeStamp value } " \
Expand All @@ -313,11 +309,14 @@ def get_vehicle_state(self, vehicle_id, minimal=False):
"windowFrontRightCalibrated { __typename timeStamp value } " \
"windowRearLeftCalibrated { __typename timeStamp value } " \
"windowRearRightCalibrated { __typename timeStamp value } " \
"windowsNextAction { __typename timeStamp value } " \
"closureFrunkLocked { __typename timeStamp value } " \
"closureFrunkClosed { __typename timeStamp value } " \
"closureFrunkNextAction { __typename timeStamp value } " \
"gearGuardLocked { __typename timeStamp value } " \
"closureLiftgateLocked { __typename timeStamp value } " \
"closureLiftgateClosed { __typename timeStamp value } " \
"closureLiftgateNextAction { __typename timeStamp value } " \
"windowRearLeftClosed { __typename timeStamp value } " \
"windowRearRightClosed { __typename timeStamp value } " \
"closureSideBinLeftLocked { __typename timeStamp value } " \
Expand Down Expand Up @@ -385,8 +384,21 @@ def get_vehicle_state(self, vehicle_id, minimal=False):
"seatFrontRightVent { __typename timeStamp value } " \
"chargerDerateStatus { __typename timeStamp value } " \
"driveMode { __typename timeStamp value } " \
"limitedAccelCold { __typename timeStamp value } " \
"limitedRegenCold { __typename timeStamp value } " \
"twelveVoltBatteryHealth { __typename timeStamp value } " \
"serviceMode { __typename timeStamp value } " \
"trailerStatus { __typename timeStamp value } " \
"btmFfHardwareFailureStatus { __typename timeStamp value } " \
"btmIcHardwareFailureStatus { __typename timeStamp value } " \
"btmLfdHardwareFailureStatus { __typename timeStamp value } " \
"btmRfHardwareFailureStatus { __typename timeStamp value } " \
"btmRfdHardwareFailureStatus { __typename timeStamp value } " \
"carWashMode { __typename timeStamp value } " \
"chargePortState { __typename timeStamp value } " \
"chargingTimeEstimationValidity { __typename timeStamp value } " \
"rearHitchStatus { __typename timeStamp value } " \
"} }"
query = "query GetVehicleState($vehicleID: String!) { vehicleState(id: $vehicleID) { __typename gnssLocation { __typename latitude longitude timeStamp } alarmSoundStatus { __typename timeStamp value } timeToEndOfCharge { __typename timeStamp value } doorFrontLeftLocked { __typename timeStamp value } doorFrontLeftClosed { __typename timeStamp value } doorFrontRightLocked { __typename timeStamp value } doorFrontRightClosed { __typename timeStamp value } doorRearLeftLocked { __typename timeStamp value } doorRearLeftClosed { __typename timeStamp value } doorRearRightLocked { __typename timeStamp value } doorRearRightClosed { __typename timeStamp value } windowFrontLeftClosed { __typename timeStamp value } windowFrontRightClosed { __typename timeStamp value } windowFrontLeftCalibrated { __typename timeStamp value } windowFrontRightCalibrated { __typename timeStamp value } windowRearLeftCalibrated { __typename timeStamp value } windowRearRightCalibrated { __typename timeStamp value } closureFrunkLocked { __typename timeStamp value } closureFrunkClosed { __typename timeStamp value } gearGuardLocked { __typename timeStamp value } closureLiftgateLocked { __typename timeStamp value } closureLiftgateClosed { __typename timeStamp value } windowRearLeftClosed { __typename timeStamp value } windowRearRightClosed { __typename timeStamp value } closureSideBinLeftLocked { __typename timeStamp value } closureSideBinLeftClosed { __typename timeStamp value } closureSideBinRightLocked { __typename timeStamp value } closureSideBinRightClosed { __typename timeStamp value } closureTailgateLocked { __typename timeStamp value } closureTailgateClosed { __typename timeStamp value } closureTonneauLocked { __typename timeStamp value } closureTonneauClosed { __typename timeStamp value } wiperFluidState { __typename timeStamp value } powerState { __typename timeStamp value } batteryHvThermalEventPropagation { __typename timeStamp value } vehicleMileage { __typename timeStamp value } brakeFluidLow { __typename timeStamp value } gearStatus { __typename timeStamp value } tirePressureStatusFrontLeft { __typename timeStamp value } tirePressureStatusValidFrontLeft { __typename timeStamp value } tirePressureStatusFrontRight { __typename timeStamp value } tirePressureStatusValidFrontRight { __typename timeStamp value } tirePressureStatusRearLeft { __typename timeStamp value } tirePressureStatusValidRearLeft { __typename timeStamp value } tirePressureStatusRearRight { __typename timeStamp value } tirePressureStatusValidRearRight { __typename timeStamp value } batteryLevel { __typename timeStamp value } chargerState { __typename timeStamp value } batteryLimit { __typename timeStamp value } remoteChargingAvailable { __typename timeStamp value } batteryHvThermalEvent { __typename timeStamp value } rangeThreshold { __typename timeStamp value } distanceToEmpty { __typename timeStamp value } otaAvailableVersionNumber { __typename timeStamp value } otaAvailableVersionWeek { __typename timeStamp value } otaAvailableVersionYear { __typename timeStamp value } otaCurrentVersionNumber { __typename timeStamp value } otaCurrentVersionWeek { __typename timeStamp value } otaCurrentVersionYear { __typename timeStamp value } otaDownloadProgress { __typename timeStamp value } otaInstallDuration { __typename timeStamp value } otaInstallProgress { __typename timeStamp value } otaInstallReady { __typename timeStamp value } otaInstallTime { __typename timeStamp value } otaInstallType { __typename timeStamp value } otaStatus { __typename timeStamp value } otaCurrentStatus { __typename timeStamp value } cabinClimateInteriorTemperature { __typename timeStamp value } cabinPreconditioningStatus { __typename timeStamp value } cabinPreconditioningType { __typename timeStamp value } petModeStatus { __typename timeStamp value } petModeTemperatureStatus { __typename timeStamp value } cabinClimateDriverTemperature { __typename timeStamp value } gearGuardVideoStatus { __typename timeStamp value } gearGuardVideoMode { __typename timeStamp value } gearGuardVideoTermsAccepted { __typename timeStamp value } defrostDefogStatus { __typename timeStamp value } steeringWheelHeat { __typename timeStamp value } seatFrontLeftHeat { __typename timeStamp value } seatFrontRightHeat { __typename timeStamp value } seatRearLeftHeat { __typename timeStamp value } seatRearRightHeat { __typename timeStamp value } chargerStatus { __typename timeStamp value } seatFrontLeftVent { __typename timeStamp value } seatFrontRightVent { __typename timeStamp value } chargerDerateStatus { __typename timeStamp value } driveMode { __typename timeStamp value } } }"

query = {
"operationName": "GetVehicleState",
Expand All @@ -395,7 +407,6 @@ def get_vehicle_state(self, vehicle_id, minimal=False):
'vehicleID': vehicle_id,
},
}

response = self.raw_graphql_query(url=RIVIAN_GATEWAY_PATH, query=query, headers=headers)
return response.json()

Expand All @@ -408,9 +419,7 @@ def get_vehicle_last_connection(self, vehicle_id):
'vehicleID': vehicle_id,
},
}

response = self.raw_graphql_query(url=RIVIAN_GATEWAY_PATH, query=query, headers=headers)
print(response)
return response.json()

def plan_trip(self, vehicle_id, starting_soc, starting_range_meters, origin_lat, origin_long, dest_lat, dest_long):
Expand Down Expand Up @@ -641,4 +650,4 @@ def send_vehicle_command(self, vehicle_id, command, vasPhoneId, deviceId, vehicl
},
}
response = self.raw_graphql_query(url=RIVIAN_GATEWAY_PATH, query=query, headers=headers)
return response.json()
return response.json()