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

Add method to get OTA details and include 2FA info in get user info request #34

Merged
merged 1 commit into from
Aug 10, 2023
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages = [
python = "^3.9"
aiohttp = ">=3.0.0"
cryptography = "^41.0.1"
backports-strenum = { version = "^1.2.4", python = "<3.11" }
backports-strenum = { version = "^1.2.4", python = "<3.11" }

[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
Expand Down
21 changes: 20 additions & 1 deletion src/rivian/rivian.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ async def get_user_information(

vehicles_fragment = "vehicles { id vin name vas { __typename vasVehicleId vehiclePublicKey } roles state createdAt updatedAt vehicle { __typename id vin modelYear make model expectedBuildDate plannedBuildDate expectedGeneralAssemblyStartDate actualGeneralAssemblyDate vehicleState { supportedFeatures { __typename name status } } } }"
phones_fragment = "enrolledPhones { __typename vas { __typename vasPhoneId publicKey } enrolled { __typename deviceType deviceName vehicleId identityId shortName } }"
_2fa_fragment = "registrationChannels { type }"

graphql_json = {
"operationName": "getUserInfo",
"query": f"query getUserInfo {{ currentUser {{ __typename id {vehicles_fragment} {phones_fragment if include_phones else ''} }} }}",
"query": f"query getUserInfo {{ currentUser {{ __typename id {vehicles_fragment} {_2fa_fragment} {phones_fragment if include_phones else ''} }} }}",
"variables": None,
}

Expand Down Expand Up @@ -394,6 +395,24 @@ async def get_vehicle_state(

return await self.__graphql_query(headers, url, graphql_json)

async def get_vehicle_ota_update_details(self, vehicle_id: str) -> ClientResponse:
"""Get vehicle OTA update details."""
url = GRAPHQL_GATEWAY
headers = BASE_HEADERS | {
"A-Sess": self._app_session_token,
"U-Sess": self._user_session_token,
}

graphql_query = "query getOTAUpdateDetails($vehicleId:String!){getVehicle(id:$vehicleId){availableOTAUpdateDetails{url version locale}currentOTAUpdateDetails{url version locale}}}"

graphql_json = {
"operationName": "getOTAUpdateDetails",
"query": graphql_query,
"variables": {"vehicleId": vehicle_id},
}

return await self.__graphql_query(headers, url, graphql_json)

async def get_live_charging_session(
self, vin: str, properties: set[str] | None = None
) -> ClientResponse:
Expand Down