carconnectivity-connector-seatcupra 0.1.2a1__py3-none-any.whl → 0.2a1__py3-none-any.whl

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.2
2
2
  Name: carconnectivity-connector-seatcupra
3
- Version: 0.1.2a1
3
+ Version: 0.2a1
4
4
  Summary: CarConnectivity connector for Seat and Cupra services
5
5
  Author: Till Steinbach
6
6
  License: MIT License
@@ -37,7 +37,7 @@ Classifier: Topic :: Software Development :: Libraries
37
37
  Requires-Python: >=3.9
38
38
  Description-Content-Type: text/markdown
39
39
  License-File: LICENSE
40
- Requires-Dist: carconnectivity>=0.4
40
+ Requires-Dist: carconnectivity>=0.5a1
41
41
  Requires-Dist: oauthlib~=3.2.2
42
42
  Requires-Dist: requests~=2.32.3
43
43
  Requires-Dist: jwt~=1.3.1
@@ -1,21 +1,21 @@
1
1
  carconnectivity_connectors/seatcupra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- carconnectivity_connectors/seatcupra/_version.py,sha256=VzTjVbsUC2B6Y5R_ncX3UCI-1y_cf0-27tYAHy1JsEY,513
2
+ carconnectivity_connectors/seatcupra/_version.py,sha256=nv-ayVPlh7g8avzeIuoqWWMLTrpQh-Tk42DRZnMODN4,508
3
3
  carconnectivity_connectors/seatcupra/capability.py,sha256=936V06hOX8AuAMxL_S9wVyVa36Xw1bo9081X0xf5f94,5064
4
4
  carconnectivity_connectors/seatcupra/charging.py,sha256=BJe_5GEB0JkP78tpU6kyKpwuwjDZHvm-kt3PTlpQHeU,3336
5
5
  carconnectivity_connectors/seatcupra/climatization.py,sha256=0xxWlxrheAPzkVT8WRQtbm6ExZmVdgW7lUdOXyS_qWY,1695
6
6
  carconnectivity_connectors/seatcupra/command_impl.py,sha256=LmBOCWGZPfJCG_4-5449xvO6NAvnPDsAWEBKlsG4WoI,3051
7
- carconnectivity_connectors/seatcupra/connector.py,sha256=llxFhVdpnL5MxmHbOej1wMio5tareY3zha0qaFhnPgs,107680
7
+ carconnectivity_connectors/seatcupra/connector.py,sha256=N2uFvzuxRj1se3157TWtQ80WSkjwh7w462D4E8c4ZlM,110344
8
8
  carconnectivity_connectors/seatcupra/vehicle.py,sha256=s0G-HqG5qcwStDxD3649KgLMa3lKPZ4TOGWRJEuQzsQ,3403
9
9
  carconnectivity_connectors/seatcupra/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  carconnectivity_connectors/seatcupra/auth/auth_util.py,sha256=Y81h8fGOMSMgPtE4wI_TI9WgE_s43uaPjRLBBINhj4g,4433
11
- carconnectivity_connectors/seatcupra/auth/my_cupra_session.py,sha256=SXO_77diYSmHN3KNSccDASk95Ko8uK5WWKSjIJNHrUA,13558
11
+ carconnectivity_connectors/seatcupra/auth/my_cupra_session.py,sha256=VF_9U8fESLkndVaPn2W1ZxZwNr9-ndeaegeTVT5FyYk,13904
12
12
  carconnectivity_connectors/seatcupra/auth/openid_session.py,sha256=pGdTSt2zMtPWD4EY8MoZTj8lT6_krfa1Xt3Fyh877FA,16972
13
13
  carconnectivity_connectors/seatcupra/auth/session_manager.py,sha256=ZIDvC848T3fy6PgGqCl8A2SzaNhu2YG19Xam5kgp7SA,5635
14
14
  carconnectivity_connectors/seatcupra/auth/vw_web_session.py,sha256=CcI6m68IyRs6WsMDu-IsW3Dj85vyGiMmxvFqNETMHO0,10929
15
15
  carconnectivity_connectors/seatcupra/auth/helpers/blacklist_retry.py,sha256=f3wsiY5bpHDBxp7Va1Mv9nKJ4u3qnCHZZmDu78_AhMk,1251
16
16
  carconnectivity_connectors/seatcupra/ui/connector_ui.py,sha256=SNYnlcGJpbWhuLiIHD2l6H9IfSiMz3IgmvXsdossDnE,1412
17
- carconnectivity_connector_seatcupra-0.1.2a1.dist-info/LICENSE,sha256=PIwI1alwDyOfvEQHdGCm2u9uf_mGE8030xZDfun0xTo,1071
18
- carconnectivity_connector_seatcupra-0.1.2a1.dist-info/METADATA,sha256=ii6XPx0SHu1N2SEXwPeDC-Pei__53Le9BlV08yKzRUw,5473
19
- carconnectivity_connector_seatcupra-0.1.2a1.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
20
- carconnectivity_connector_seatcupra-0.1.2a1.dist-info/top_level.txt,sha256=KqA8GviZsDH4PtmnwSQsz0HB_w-TWkeEHLIRNo5dTaI,27
21
- carconnectivity_connector_seatcupra-0.1.2a1.dist-info/RECORD,,
17
+ carconnectivity_connector_seatcupra-0.2a1.dist-info/LICENSE,sha256=PIwI1alwDyOfvEQHdGCm2u9uf_mGE8030xZDfun0xTo,1071
18
+ carconnectivity_connector_seatcupra-0.2a1.dist-info/METADATA,sha256=-evGY15ib_P4dy75Cnjmm-Q_u8GOqFK6Nk_XGHNMbAs,5473
19
+ carconnectivity_connector_seatcupra-0.2a1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
20
+ carconnectivity_connector_seatcupra-0.2a1.dist-info/top_level.txt,sha256=KqA8GviZsDH4PtmnwSQsz0HB_w-TWkeEHLIRNo5dTaI,27
21
+ carconnectivity_connector_seatcupra-0.2a1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.2a1'
21
- __version_tuple__ = version_tuple = (0, 1, 2)
20
+ __version__ = version = '0.2a1'
21
+ __version_tuple__ = version_tuple = (0, 2)
@@ -46,6 +46,7 @@ class MyCupraSession(VWWebSession):
46
46
 
47
47
  self.headers = CaseInsensitiveDict({
48
48
  'accept': '*/*',
49
+ 'connection': 'keep-alive',
49
50
  'content-type': 'application/json',
50
51
  'user-agent': 'SEATApp/2.5.0 (com.seat.myseat.ola; build:202410171614; iOS 15.8.3) Alamofire/5.7.0 Mobile',
51
52
  'accept-language': 'de-de',
@@ -62,6 +63,7 @@ class MyCupraSession(VWWebSession):
62
63
 
63
64
  self.headers = CaseInsensitiveDict({
64
65
  'accept': '*/*',
66
+ 'connection': 'keep-alive',
65
67
  'content-type': 'application/json',
66
68
  'user-agent': 'CUPRAApp%20-%20Store/20220503 CFNetwork/1333.0.4 Darwin/21.5.0',
67
69
  'accept-language': 'de-de',
@@ -220,12 +222,19 @@ class MyCupraSession(VWWebSession):
220
222
  if headers is None:
221
223
  headers = dict(self.headers)
222
224
 
223
- body: Dict[str, str] = {
224
- 'client_id': self.client_id,
225
- 'client_secret': 'eb8814e641c81a2640ad62eeccec11c98effc9bccd4269ab7af338b50a94b3a2',
226
- 'grant_type': 'refresh_token',
227
- 'refresh_token': self.refresh_token
228
- }
225
+ if self.is_seat:
226
+ body: Dict[str, str] = {
227
+ 'client_id': self.client_id,
228
+ 'grant_type': 'refresh_token',
229
+ 'refresh_token': self.refresh_token
230
+ }
231
+ else:
232
+ body: Dict[str, str] = {
233
+ 'client_id': self.client_id,
234
+ 'client_secret': 'eb8814e641c81a2640ad62eeccec11c98effc9bccd4269ab7af338b50a94b3a2',
235
+ 'grant_type': 'refresh_token',
236
+ 'refresh_token': self.refresh_token
237
+ }
229
238
 
230
239
  headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
231
240
 
@@ -20,7 +20,7 @@ from carconnectivity.units import Length, Current
20
20
  from carconnectivity.doors import Doors
21
21
  from carconnectivity.windows import Windows
22
22
  from carconnectivity.lights import Lights
23
- from carconnectivity.drive import GenericDrive, ElectricDrive, CombustionDrive
23
+ from carconnectivity.drive import GenericDrive, ElectricDrive, CombustionDrive, DieselDrive
24
24
  from carconnectivity.vehicle import GenericVehicle, ElectricVehicle
25
25
  from carconnectivity.attributes import BooleanAttribute, DurationAttribute, GenericAttribute, TemperatureAttribute, EnumAttribute
26
26
  from carconnectivity.units import Temperature
@@ -288,6 +288,7 @@ class Connector(BaseConnector):
288
288
  vehicle_to_update = self.fetch_vehicle_status(vehicle_to_update)
289
289
  vehicle_to_update = self.fetch_vehicle_mycar_status(vehicle_to_update)
290
290
  vehicle_to_update = self.fetch_mileage(vehicle_to_update)
291
+ vehicle_to_update = self.fetch_ranges(vehicle_to_update)
291
292
  if vehicle_to_update.capabilities.has_capability('climatisation', check_status_ok=True):
292
293
  vehicle_to_update = self.fetch_climatisation(vehicle_to_update)
293
294
  if vehicle_to_update.capabilities.has_capability('charging', check_status_ok=True):
@@ -414,7 +415,7 @@ class Connector(BaseConnector):
414
415
  capability.parameters[parameter] = value
415
416
  else:
416
417
  raise APIError('Could not fetch capabilities, capability ID missing')
417
- log_extra_keys(LOG_API, 'capability', capability_dict, {'id', 'expirationDate', 'editable', 'parameters'})
418
+ log_extra_keys(LOG_API, 'capability', capability_dict, {'id', 'expirationDate', 'editable', 'parameters', 'status'})
418
419
 
419
420
  for capability_id in vehicle.capabilities.capabilities.keys() - found_capabilities:
420
421
  vehicle.capabilities.remove_capability(capability_id)
@@ -646,6 +647,8 @@ class Connector(BaseConnector):
646
647
  else:
647
648
  if engine_type == GenericDrive.Type.ELECTRIC:
648
649
  drive = ElectricDrive(drive_id=drive_id, drives=vehicle.drives)
650
+ elif engine_type == GenericDrive.Type.DIESEL:
651
+ drive = DieselDrive(drive_id=drive_id, drives=vehicle.drives)
649
652
  elif engine_type in [GenericDrive.Type.FUEL,
650
653
  GenericDrive.Type.GASOLINE,
651
654
  GenericDrive.Type.PETROL,
@@ -845,6 +848,36 @@ class Connector(BaseConnector):
845
848
  vehicle.odometer._set_value(None) # pylint: disable=protected-access
846
849
  return vehicle
847
850
 
851
+ def fetch_ranges(self, vehicle: SeatCupraVehicle, no_cache: bool = False) -> SeatCupraVehicle:
852
+ vin = vehicle.vin.value
853
+ if vin is None:
854
+ raise APIError('VIN is missing')
855
+ url = f'https://ola.prod.code.seat.cloud.vwgroup.com/v1/vehicles/{vin}/ranges'
856
+ # {'ranges': [{'rangeName': 'gasolineRangeKm', 'value': 100.0}, {'rangeName': 'electricRangeKm', 'value': 28.0}]}
857
+ data: Dict[str, Any] | None = self._fetch_data(url=url, session=self.session, no_cache=no_cache)
858
+ if data is not None:
859
+ if 'ranges' in data and data['ranges'] is not None:
860
+ for drive in vehicle.drives.drives.values():
861
+ if drive.type.enabled and drive.type.value == GenericDrive.Type.ELECTRIC:
862
+ for range_dict in data['ranges']:
863
+ if 'electricRangeKm' in range_dict and range_dict['electricRangeKm'] is not None:
864
+ drive.range._set_value(range_dict['electricRangeKm'], unit=Length.KM) # pylint: disable=protected-access
865
+ break
866
+ elif drive.type.enabled and drive.type.value == GenericDrive.Type.GASOLINE:
867
+ for range_dict in data['ranges']:
868
+ if 'gasolineRangeKm' in range_dict and range_dict['gasolineRangeKm'] is not None:
869
+ drive.range._set_value(range_dict['gasolineRangeKm'], unit=Length.KM) # pylint: disable=protected-access
870
+ break
871
+ elif drive.type.enabled and drive.type.value == GenericDrive.Type.DIESEL:
872
+ for range_dict in data['ranges']:
873
+ if 'dieselRangeKm' in range_dict and range_dict['dieselRangeKm'] is not None:
874
+ drive.range._set_value(range_dict['dieselRangeKm'], unit=Length.KM) # pylint: disable=protected-access
875
+ elif 'adBlueKm' in range_dict and range_dict['adBlueKm'] is not None:
876
+ if isinstance(drive, DieselDrive):
877
+ drive.adblue_range._set_value(range_dict['adBlueKm'], unit=Length.KM) # pylint: disable=protected-access
878
+ log_extra_keys(LOG_API, f'https://ola.prod.code.seat.cloud.vwgroup.com/v1/vehicles/{vin}/ranges', data, {'ranges'})
879
+ return vehicle
880
+
848
881
  def fetch_maintenance(self, vehicle: SeatCupraVehicle, no_cache: bool = False) -> SeatCupraVehicle:
849
882
  vin = vehicle.vin.value
850
883
  if vin is None: