rivian-python-client 1.1.2__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rivian-python-client
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Rivian API Client (Unofficial)
5
5
  License: MIT
6
6
  Author: Brian Retterer
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
15
15
  Provides-Extra: ble
16
16
  Requires-Dist: aiohttp (>=3.0.0)
17
17
  Requires-Dist: backports-strenum (>=1.2.4,<2.0.0) ; python_version < "3.11"
18
- Requires-Dist: bleak (>=0.21,<0.22) ; extra == "ble"
18
+ Requires-Dist: bleak (>=0.21,<1.0.0) ; extra == "ble"
19
19
  Requires-Dist: cryptography (>=41.0.1,<43.0)
20
20
  Requires-Dist: dbus-fast (>=2.11.0,<3.0.0) ; (sys_platform == "linux") and (extra == "ble")
21
21
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "rivian-python-client"
3
- version = "1.1.2"
3
+ version = "1.2.0"
4
4
  description = "Rivian API Client (Unofficial)"
5
5
  readme = "README.md"
6
6
  authors = ["Brian Retterer <bretterer@gmail.com>"]
@@ -10,19 +10,20 @@ packages = [
10
10
  ]
11
11
 
12
12
  [tool.poetry.dependencies]
13
- python = ">=3.9, <3.13"
13
+ python = ">=3.9,<3.13"
14
14
  aiohttp = ">=3.0.0"
15
- cryptography = ">=41.0.1, <43.0"
15
+ cryptography = ">=41.0.1,<43.0"
16
16
  backports-strenum = { version = "^1.2.4", python = "<3.11" }
17
- bleak = { version = "^0.21", optional = true }
17
+ bleak = { version = ">=0.21,<1.0.0", optional = true }
18
18
  dbus-fast = {version = "^2.11.0", optional = true, platform = "linux"}
19
19
 
20
20
  [tool.poetry.group.dev.dependencies]
21
- pytest = "^7.1.2"
21
+ pytest = ">=7.1.2,<9.0.0"
22
22
  pytest-asyncio = ">=0.18.3,<0.24.0"
23
23
  python-dotenv = ">=0.20,<1.1"
24
- aresponses = "^2.1.5"
25
- mypy = "^1.7.0"
24
+ aresponses = ">=2.1.5,<4.0.0"
25
+ mypy = ">=1.7.0,<2.0.0"
26
+ ruff = "^0.4"
26
27
 
27
28
  [tool.poetry.extras]
28
29
  ble = ["bleak", "dbus-fast"]
@@ -33,6 +34,10 @@ vcs = "git"
33
34
  style = "semver"
34
35
  pattern = "default-unprefixed"
35
36
 
37
+ [tool.ruff.lint.isort]
38
+ combine-as-imports = true
39
+ split-on-trailing-comma = false
40
+
36
41
  [build-system]
37
42
  requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
38
43
  build-backend = "poetry_dynamic_versioning.backend"
@@ -1,4 +1,5 @@
1
1
  """Rivian BLE handler."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import asyncio
@@ -1,4 +1,5 @@
1
1
  """Rivian constants."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import sys
@@ -1,9 +1,11 @@
1
1
  """Asynchronous Python client for the Rivian API."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import asyncio
5
6
  import logging
6
7
  import socket
8
+ import sys
7
9
  import time
8
10
  import uuid
9
11
  from collections.abc import Callable
@@ -11,7 +13,6 @@ from typing import Any, Type
11
13
  from warnings import warn
12
14
 
13
15
  import aiohttp
14
- import async_timeout
15
16
  from aiohttp import ClientResponse, ClientWebSocketResponse
16
17
 
17
18
  from .const import LIVE_SESSION_PROPERTIES, VEHICLE_STATE_PROPERTIES, VehicleCommand
@@ -29,6 +30,11 @@ from .exceptions import (
29
30
  from .utils import generate_vehicle_command_hmac
30
31
  from .ws_monitor import WebSocketMonitor
31
32
 
33
+ if sys.version_info >= (3, 11):
34
+ import asyncio as async_timeout
35
+ else:
36
+ import async_timeout
37
+
32
38
  _LOGGER = logging.getLogger(__name__)
33
39
 
34
40
  GRAPHQL_BASEPATH = "https://rivian.com/api/gql"
@@ -379,7 +385,7 @@ class Rivian:
379
385
  "U-Sess": self._user_session_token,
380
386
  }
381
387
 
382
- graphql_query = "query getVehicleImages( $extension: String $resolution: String $versionForVehicle: String $versionForPreOrder: String ) { getVehicleOrderMobileImages( resolution: $resolution extension: $extension version: $versionForPreOrder ) { ...image } getVehicleMobileImages( resolution: $resolution extension: $extension version: $versionForVehicle ) { ...image } } fragment image on VehicleMobileImage { orderId vehicleId url extension resolution size design placement }"
388
+ graphql_query = "query getVehicleImages( $extension: String $resolution: String $versionForVehicle: String $versionForPreOrder: String ) { getVehicleOrderMobileImages( resolution: $resolution extension: $extension version: $versionForPreOrder ) { ...image } getVehicleMobileImages( resolution: $resolution extension: $extension version: $versionForVehicle ) { ...image } } fragment image on VehicleMobileImage { orderId vehicleId url extension resolution size design placement overlays { url overlay zIndex } }"
383
389
 
384
390
  graphql_json = {
385
391
  "operationName": "getVehicleImages",
@@ -28,6 +28,12 @@ type Query {
28
28
 
29
29
  type Mutation {
30
30
  createCsrfToken: CreateCsrfTokenResponse
31
+ createDepartureSchedule(
32
+ vehicleId: String!
33
+ schedule: InputDepartureSchedule!
34
+ ): Success
35
+ deleteDepartureSchedule(vehicleId: String!, scheduleId: String!): Success
36
+ departNow(vehicleId: String!, scheduleId: String!, skipDate: String!): Success
31
37
  disenrollPhone(attrs: DisenrollPhoneAttributes!): DisenrollPhoneResponse
32
38
  enrollPhone(attrs: EnrollPhoneAttributes!): EnrollPhoneResponse
33
39
  login(email: String!, password: String!): LoginResponse
@@ -36,16 +42,61 @@ type Mutation {
36
42
  otpToken: String!
37
43
  otpCode: String!
38
44
  ): MobileLoginResponse
45
+ logout: LogoutResponse
46
+ resendOTPCode(otpToken: String!): ResendOTPCodeResponse
39
47
  sendVehicleCommand(attrs: VehicleCommandAttributes!): SendVehicleCommandState
40
48
  setChargingSchedules(
41
49
  vehicleId: String!
42
50
  chargingSchedules: [InputChargingSchedule!]!
43
51
  ): OK
44
52
  setVehicleName(vehicleId: String!, name: String!): OK
53
+ skipNextScheduledDeparture(
54
+ vehicleId: String!
55
+ scheduleId: String!
56
+ skipDate: String!
57
+ ): Success
58
+ updateDepartureSchedule(
59
+ vehicleId: String!
60
+ scheduleId: String!
61
+ schedule: InputDepartureSchedule!
62
+ ): Success
45
63
  }
46
64
 
47
65
  type Subscription {
48
- vehicleState(id: String!): VehicleState
66
+ chargingSession(vehicleId: String!): ChargingSession!
67
+ otaInstallSchedules(vehicleId: String!): ParallaxMessageResponse!
68
+ otaInstallState(vehicleId: String!): ParallaxMessageResponse!
69
+ vehicleCloudConnection(id: String!): VehicleCloudConnection!
70
+ vehicleCommandState(id: String!): GetVehicleCommandState!
71
+ vehicleDepartureSchedules(vehicleId: String!): [DepartureSchedule!]!
72
+ vehicleGeofences(vehicleId: String!): ParallaxMessageResponse
73
+ vehicleState(id: String!): VehicleState!
74
+ }
75
+
76
+ enum DefogDefrostLevel {
77
+ Off
78
+ Defog
79
+ Defrost
80
+ }
81
+
82
+ enum SurfaceHeatVentLevel {
83
+ Off
84
+ Heat1
85
+ Heat2
86
+ Heat3
87
+ Vent1
88
+ Vent2
89
+ Vent3
90
+ }
91
+
92
+ enum WeekDay {
93
+ Monday
94
+ Tuesday
95
+ Wednesday
96
+ Thursday
97
+ Friday
98
+ Saturday
99
+ Sunday
49
100
  }
50
101
 
51
102
  input CoordinatesInput {
@@ -74,6 +125,38 @@ input InputChargingSchedule {
74
125
  enabled: Boolean!
75
126
  }
76
127
 
128
+ input InputComfortSettings {
129
+ surfaceHeatVentLevels: InputSurfaceHeatVentLevels!
130
+ cabinTempCelsius: Float!
131
+ frontDefogDefrost: DefogDefrostLevel!
132
+ }
133
+
134
+ input InputDepartureSchedule {
135
+ name: String!
136
+ isEnabled: Boolean!
137
+ repeatsWeekly: InputRepeatsWeekly!
138
+ departureSettings: InputDepartureSettings!
139
+ }
140
+
141
+ input InputDepartureSettings {
142
+ shouldOverrideChargeSchedule: Boolean!
143
+ comfortSettings: InputComfortSettings!
144
+ }
145
+
146
+ input InputRepeatsWeekly {
147
+ days: [WeekDay!]!
148
+ startsAtMin: Int!
149
+ skippedOn: [String!]!
150
+ }
151
+
152
+ input InputSurfaceHeatVentLevels {
153
+ frontLeftSeat: SurfaceHeatVentLevel!
154
+ frontRightSeat: SurfaceHeatVentLevel!
155
+ rearLeftSeat: SurfaceHeatVentLevel!
156
+ rearRightSeat: SurfaceHeatVentLevel!
157
+ steeringWheel: SurfaceHeatVentLevel!
158
+ }
159
+
77
160
  input NetworkPreference {
78
161
  networkId: String!
79
162
  preference: Float
@@ -104,6 +187,27 @@ type CampSpeaker {
104
187
  serialNumber: String!
105
188
  }
106
189
 
190
+ type ChargingChartData {
191
+ soc: Float!
192
+ powerKW: Float!
193
+ startTime: Float!
194
+ endTime: Float!
195
+ timeEstimationValidityStatus: String!
196
+ vehicleChargerState: String!
197
+ }
198
+
199
+ type ChargingLiveData {
200
+ powerKW: Float!
201
+ kilometersChargedPerHour: Float!
202
+ rangeAddedThisSession: Float!
203
+ totalChargedEnergy: Float!
204
+ timeElapsed: Float
205
+ timeRemaining: Float
206
+ price: Float
207
+ currency: String
208
+ isFreeSession: Boolean
209
+ }
210
+
107
211
  type ChargingSchedule {
108
212
  startTime: Int!
109
213
  duration: Int!
@@ -113,6 +217,17 @@ type ChargingSchedule {
113
217
  weekDays: [String!]!
114
218
  }
115
219
 
220
+ type ChargingSession {
221
+ chartData: [ChargingChartData!]!
222
+ liveData: ChargingLiveData!
223
+ }
224
+
225
+ type ComfortSettings {
226
+ surfaceHeatVentLevels: SurfaceHeatVentLevels!
227
+ cabinTempCelsius: Float!
228
+ frontDefogDefrost: DefogDefrostLevel!
229
+ }
230
+
116
231
  type CreateCsrfTokenResponse {
117
232
  csrfToken: String!
118
233
  appSessionToken: String!
@@ -142,6 +257,19 @@ type DeliveryAppointment {
142
257
  timeZone: String!
143
258
  }
144
259
 
260
+ type DepartureSchedule {
261
+ id: String!
262
+ name: String!
263
+ isEnabled: Boolean!
264
+ occurrence: RepeatsWeekly!
265
+ departureSettings: DepartureSettings!
266
+ }
267
+
268
+ type DepartureSettings {
269
+ shouldOverrideChargeSchedule: Boolean!
270
+ comfortSettings: ComfortSettings!
271
+ }
272
+
145
273
  type DisenrollPhoneResponse {
146
274
  success: Boolean!
147
275
  }
@@ -164,6 +292,10 @@ type GetVehicleCommandState {
164
292
  statusCode: Int
165
293
  }
166
294
 
295
+ type LogoutResponse {
296
+ success: Boolean!
297
+ }
298
+
167
299
  type MobileLoginResponse {
168
300
  accessToken: String!
169
301
  refreshToken: String!
@@ -189,6 +321,11 @@ type OTAUpdateDetails {
189
321
  locale: String!
190
322
  }
191
323
 
324
+ type ParallaxMessageResponse {
325
+ payload: String! # base64 encoded??
326
+ sequenceNumber: Int!
327
+ }
328
+
192
329
  type PlanTripResponse {
193
330
  routes: [Route!]!
194
331
  tripPlanStatus: String!
@@ -219,6 +356,16 @@ type RegistrationChannel {
219
356
  type: String!
220
357
  }
221
358
 
359
+ type RepeatsWeekly {
360
+ days: [WeekDay!]!
361
+ startsAtMin: Int!
362
+ skippedOn: [String!]!
363
+ }
364
+
365
+ type ResendOTPCodeResponse {
366
+ success: Boolean!
367
+ }
368
+
222
369
  type Route {
223
370
  routeResponse: String!
224
371
  destinationReached: Boolean!
@@ -238,11 +385,23 @@ type SendVehicleCommandState {
238
385
  state: Int!
239
386
  }
240
387
 
388
+ type Success {
389
+ success: Boolean!
390
+ }
391
+
241
392
  type SupportedFeature {
242
393
  name: String!
243
394
  status: String!
244
395
  }
245
396
 
397
+ type SurfaceHeatVentLevels {
398
+ frontLeftSeat: SurfaceHeatVentLevel!
399
+ frontRightSeat: SurfaceHeatVentLevel!
400
+ rearLeftSeat: SurfaceHeatVentLevel!
401
+ rearRightSeat: SurfaceHeatVentLevel!
402
+ steeringWheel: SurfaceHeatVentLevel!
403
+ }
404
+
246
405
  type TimeStampedFloat implements TimeStamped {
247
406
  timeStamp: String!
248
407
  value: Float!
@@ -366,13 +525,23 @@ type Vehicle {
366
525
  }
367
526
 
368
527
  type VehicleCloudConnection {
369
- lastSync: String!
528
+ isOnline: Boolean!
529
+ lastSync: String
370
530
  }
371
531
 
372
532
  type VehicleLocation implements TimeStamped {
373
533
  timeStamp: String!
374
534
  latitude: Float!
375
535
  longitude: Float!
536
+ isAuthorized: Boolean
537
+ }
538
+
539
+ type VehicleLocationError implements TimeStamped {
540
+ timeStamp: String!
541
+ bearing: Float!
542
+ positionHorizontal: Float!
543
+ positionVertical: Float!
544
+ speed: Float!
376
545
  }
377
546
 
378
547
  type VehicleMobileConfiguration {
@@ -396,6 +565,13 @@ type VehicleMobileImage {
396
565
  resolution: String!
397
566
  size: String!
398
567
  url: String!
568
+ overlays: [VehicleMobileImageOverlay!]!
569
+ }
570
+
571
+ type VehicleMobileImageOverlay {
572
+ url: String!
573
+ overlay: String!
574
+ zIndex: Int!
399
575
  }
400
576
 
401
577
  type VehicleState {
@@ -422,9 +598,13 @@ type VehicleState {
422
598
 
423
599
  carWashMode: TimeStampedString
424
600
 
601
+ chargePortState: TimeStampedString
425
602
  chargerDerateStatus: TimeStampedString
426
603
  chargerState: TimeStampedString
427
604
  chargerStatus: TimeStampedString
605
+ chargingDisabledAC: TimeStampedInt
606
+ chargingDisabledAll: TimeStampedInt
607
+ chargingTimeEstimationValidity: TimeStampedString
428
608
 
429
609
  closureFrunkClosed: TimeStampedString
430
610
  closureFrunkLocked: TimeStampedString
@@ -470,6 +650,7 @@ type VehicleState {
470
650
 
471
651
  gnssAltitude: TimeStampedNullableFloat
472
652
  gnssBearing: TimeStampedFloat
653
+ gnssError: VehicleLocationError
473
654
  gnssLocation: VehicleLocation
474
655
  gnssSpeed: TimeStampedFloat
475
656
 
@@ -502,6 +683,8 @@ type VehicleState {
502
683
 
503
684
  rangeThreshold: TimeStampedString
504
685
 
686
+ rearHitchStatus: TimeStampedString
687
+
505
688
  remoteChargingAvailable: TimeStampedInt
506
689
 
507
690
  seatFrontLeftHeat: TimeStampedString
@@ -519,6 +702,10 @@ type VehicleState {
519
702
 
520
703
  timeToEndOfCharge: TimeStampedFloat
521
704
 
705
+ tirePressureFrontLeft: TimeStampedNullableFloat # only available via subscription
706
+ tirePressureFrontRight: TimeStampedNullableFloat # only available via subscription
707
+ tirePressureRearLeft: TimeStampedNullableFloat # only available via subscription
708
+ tirePressureRearRight: TimeStampedNullableFloat # only available via subscription
522
709
  tirePressureStatusFrontLeft: TimeStampedString
523
710
  tirePressureStatusFrontRight: TimeStampedString
524
711
  tirePressureStatusRearLeft: TimeStampedString
@@ -1,4 +1,5 @@
1
1
  """Utilities."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import hashlib
@@ -1,8 +1,10 @@
1
1
  """Websocket monitor."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import asyncio
5
6
  import logging
7
+ import sys
6
8
  from collections.abc import Awaitable, Callable
7
9
  from datetime import datetime, timezone
8
10
  from json import loads
@@ -10,9 +12,13 @@ from random import uniform
10
12
  from typing import TYPE_CHECKING, Any
11
13
  from uuid import uuid4
12
14
 
13
- import async_timeout
14
15
  from aiohttp import ClientWebSocketResponse, WSMessage, WSMsgType
15
16
 
17
+ if sys.version_info >= (3, 11):
18
+ import asyncio as async_timeout
19
+ else:
20
+ import async_timeout
21
+
16
22
  if TYPE_CHECKING:
17
23
  from .rivian import Rivian
18
24