carconnectivity-connector-seatcupra 0.1a9__tar.gz → 0.1a10__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.
Files changed (39) hide show
  1. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/PKG-INFO +1 -1
  2. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connector_seatcupra.egg-info/PKG-INFO +1 -1
  3. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/_version.py +1 -1
  4. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/connector.py +46 -23
  5. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.flake8 +0 -0
  6. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  7. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  8. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/dependabot.yml +0 -0
  9. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/workflows/build.yml +0 -0
  10. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/workflows/build_and_publish.yml +0 -0
  11. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.github/workflows/codeql-analysis.yml +0 -0
  12. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/.gitignore +0 -0
  13. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/CHANGELOG.md +0 -0
  14. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/LICENSE +0 -0
  15. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/Makefile +0 -0
  16. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/README.md +0 -0
  17. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/doc/Config.md +0 -0
  18. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/pyproject.toml +0 -0
  19. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/setup.cfg +0 -0
  20. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/setup_requirements.txt +0 -0
  21. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connector_seatcupra.egg-info/SOURCES.txt +0 -0
  22. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connector_seatcupra.egg-info/dependency_links.txt +0 -0
  23. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connector_seatcupra.egg-info/requires.txt +0 -0
  24. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connector_seatcupra.egg-info/top_level.txt +0 -0
  25. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/__init__.py +0 -0
  26. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/__init__.py +0 -0
  27. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/auth_util.py +0 -0
  28. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/helpers/blacklist_retry.py +0 -0
  29. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/my_cupra_session.py +0 -0
  30. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/openid_session.py +0 -0
  31. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/session_manager.py +0 -0
  32. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/auth/vw_web_session.py +0 -0
  33. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/capability.py +0 -0
  34. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/charging.py +0 -0
  35. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/climatization.py +0 -0
  36. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/command_impl.py +0 -0
  37. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/ui/connector_ui.py +0 -0
  38. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/src/carconnectivity_connectors/seatcupra/vehicle.py +0 -0
  39. {carconnectivity_connector_seatcupra-0.1a9 → carconnectivity_connector_seatcupra-0.1a10}/test/integration_test/carConnectivity.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: carconnectivity-connector-seatcupra
3
- Version: 0.1a9
3
+ Version: 0.1a10
4
4
  Summary: CarConnectivity connector for Seat and Cupra services
5
5
  Author: Till Steinbach
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: carconnectivity-connector-seatcupra
3
- Version: 0.1a9
3
+ Version: 0.1a10
4
4
  Summary: CarConnectivity connector for Seat and Cupra services
5
5
  Author: Till Steinbach
6
6
  License: MIT License
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1a9'
20
+ __version__ = version = '0.1a10'
21
21
  __version_tuple__ = version_tuple = (0, 1)
@@ -252,8 +252,8 @@ class Connector(BaseConnector):
252
252
  Updates the status of all vehicles in the garage managed by this connector.
253
253
 
254
254
  This method iterates through all vehicle VINs in the garage, and for each vehicle that is
255
- managed by this connector and is an instance of SkodaVehicle, it updates the vehicle's status
256
- by fetching data from various APIs. If the vehicle is an instance of SkodaElectricVehicle,
255
+ managed by this connector and is an instance of Seat/CupraVehicle, it updates the vehicle's status
256
+ by fetching data from various APIs. If the vehicle is an instance of Seat/CupraElectricVehicle,
257
257
  it also fetches charging information.
258
258
 
259
259
  Returns:
@@ -277,8 +277,8 @@ class Connector(BaseConnector):
277
277
 
278
278
  def fetch_vehicles(self) -> None:
279
279
  """
280
- Fetches the list of vehicles from the Skoda Connect API and updates the garage with new vehicles.
281
- This method sends a request to the Skoda Connect API to retrieve the list of vehicles associated with the user's account.
280
+ Fetches the list of vehicles from the Seat/Cupra Connect API and updates the garage with new vehicles.
281
+ This method sends a request to the Seat/Cupra Connect API to retrieve the list of vehicles associated with the user's account.
282
282
  If new vehicles are found in the response, they are added to the garage.
283
283
 
284
284
  Returns:
@@ -688,10 +688,10 @@ class Connector(BaseConnector):
688
688
  Fetches the position of the given vehicle and updates its position attributes.
689
689
 
690
690
  Args:
691
- vehicle (SkodaVehicle): The vehicle object containing the VIN and position attributes.
691
+ vehicle (Seat/CupraVehicle): The vehicle object containing the VIN and position attributes.
692
692
 
693
693
  Returns:
694
- SkodaVehicle: The updated vehicle object with the fetched position data.
694
+ Seat/CupraVehicle: The updated vehicle object with the fetched position data.
695
695
 
696
696
  Raises:
697
697
  APIError: If the VIN is missing.
@@ -728,10 +728,10 @@ class Connector(BaseConnector):
728
728
  Fetches the mileage of the given vehicle and updates its mileage attributes.
729
729
 
730
730
  Args:
731
- vehicle (SkodaVehicle): The vehicle object containing the VIN and mileage attributes.
731
+ vehicle (Seat/CupraVehicle): The vehicle object containing the VIN and mileage attributes.
732
732
 
733
733
  Returns:
734
- SkodaVehicle: The updated vehicle object with the fetched mileage data.
734
+ Seat/CupraVehicle: The updated vehicle object with the fetched mileage data.
735
735
 
736
736
  Raises:
737
737
  APIError: If the VIN is missing.
@@ -793,10 +793,10 @@ class Connector(BaseConnector):
793
793
  Fetches the mileage of the given vehicle and updates its mileage attributes.
794
794
 
795
795
  Args:
796
- vehicle (SkodaVehicle): The vehicle object containing the VIN and mileage attributes.
796
+ vehicle (Seat/CupraVehicle): The vehicle object containing the VIN and mileage attributes.
797
797
 
798
798
  Returns:
799
- SkodaVehicle: The updated vehicle object with the fetched mileage data.
799
+ Seat/CupraVehicle: The updated vehicle object with the fetched mileage data.
800
800
 
801
801
  Raises:
802
802
  APIError: If the VIN is missing.
@@ -876,10 +876,10 @@ class Connector(BaseConnector):
876
876
  Fetches the mileage of the given vehicle and updates its mileage attributes.
877
877
 
878
878
  Args:
879
- vehicle (SkodaVehicle): The vehicle object containing the VIN and mileage attributes.
879
+ vehicle (Seat/CupraVehicle): The vehicle object containing the VIN and mileage attributes.
880
880
 
881
881
  Returns:
882
- SkodaVehicle: The updated vehicle object with the fetched mileage data.
882
+ Seat/CupraVehicle: The updated vehicle object with the fetched mileage data.
883
883
 
884
884
  Raises:
885
885
  APIError: If the VIN is missing.
@@ -1074,7 +1074,7 @@ class Connector(BaseConnector):
1074
1074
  raise RetrievalError(f'Could not fetch data. Status Code was: {status_response.status_code}')
1075
1075
  except requests.exceptions.ConnectionError as connection_error:
1076
1076
  raise RetrievalError(f'Connection error: {connection_error}.'
1077
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1077
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1078
1078
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1079
1079
  raise RetrievalError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1080
1080
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1126,7 +1126,7 @@ class Connector(BaseConnector):
1126
1126
  raise CommandError(f'Could not start/stop charging ({command_response.status_code}: {command_response.text})')
1127
1127
  except requests.exceptions.ConnectionError as connection_error:
1128
1128
  raise CommandError(f'Connection error: {connection_error}.'
1129
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1129
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1130
1130
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1131
1131
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1132
1132
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1185,7 +1185,7 @@ class Connector(BaseConnector):
1185
1185
  raise CommandError(f'Could not start/stop air conditioning ({command_response.status_code}: {command_response.text})')
1186
1186
  except requests.exceptions.ConnectionError as connection_error:
1187
1187
  raise CommandError(f'Connection error: {connection_error}.'
1188
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1188
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1189
1189
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1190
1190
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1191
1191
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1194,6 +1194,24 @@ class Connector(BaseConnector):
1194
1194
  raise CommandError(f'Retrying failed: {retry_error}') from retry_error
1195
1195
  return command_arguments
1196
1196
 
1197
+ def __fetchSecurityToken(self, spin: str) -> str:
1198
+ """
1199
+ Fetches the security token from the server.
1200
+
1201
+ Returns:
1202
+ str: The security token.
1203
+ """
1204
+ command_dict = {'spin': spin}
1205
+ url = f'https://ola.prod.code.seat.cloud.vwgroup.com/v2/users/{self.session.user_id}/spin/verify'
1206
+ spin_verify_response: requests.Response = self.session.post(url, data=json.dumps(command_dict), allow_redirects=True)
1207
+ if spin_verify_response.status_code != requests.codes['ok']:
1208
+ raise AuthenticationError(f'Could not fetch security token ({spin_verify_response.status_code}: {spin_verify_response.text})')
1209
+ data = spin_verify_response.json()
1210
+ if 'securityToken' in data:
1211
+ return data['securityToken']
1212
+ raise AuthenticationError('Could not fetch security token')
1213
+
1214
+
1197
1215
  def __on_spin(self, spin_command: SpinCommand, command_arguments: Union[str, Dict[str, Any]]) \
1198
1216
  -> Union[str, Dict[str, Any]]:
1199
1217
  del spin_command
@@ -1223,7 +1241,7 @@ class Connector(BaseConnector):
1223
1241
  LOG.info('Spin verify command executed successfully')
1224
1242
  except requests.exceptions.ConnectionError as connection_error:
1225
1243
  raise CommandError(f'Connection error: {connection_error}.'
1226
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1244
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1227
1245
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1228
1246
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1229
1247
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1255,7 +1273,7 @@ class Connector(BaseConnector):
1255
1273
  raise CommandError(f'Could not execute wake command ({command_response.status_code}: {command_response.text})')
1256
1274
  except requests.exceptions.ConnectionError as connection_error:
1257
1275
  raise CommandError(f'Connection error: {connection_error}.'
1258
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1276
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1259
1277
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1260
1278
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1261
1279
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1304,7 +1322,7 @@ class Connector(BaseConnector):
1304
1322
  raise CommandError(f'Could not execute honk or flash command ({command_response.status_code}: {command_response.text})')
1305
1323
  except requests.exceptions.ConnectionError as connection_error:
1306
1324
  raise CommandError(f'Connection error: {connection_error}.'
1307
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1325
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1308
1326
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1309
1327
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1310
1328
  except requests.exceptions.ReadTimeout as timeout_error:
@@ -1330,11 +1348,12 @@ class Connector(BaseConnector):
1330
1348
  raise CommandError('Command argument missing')
1331
1349
  command_dict = {}
1332
1350
  if 'spin' in command_arguments:
1333
- command_dict['spin'] = command_arguments['spin']
1351
+ spin = command_arguments['spin']
1334
1352
  else:
1335
1353
  if self.active_config['spin'] is None:
1336
1354
  raise CommandError('S-PIN is missing, please add S-PIN to your configuration or .netrc file')
1337
- command_dict['spin'] = self.active_config['spin']
1355
+ spin = self.active_config['spin']
1356
+ sec_token = self.__fetchSecurityToken(spin)
1338
1357
  if command_arguments['command'] == LockUnlockCommand.Command.LOCK:
1339
1358
  url = f'https://ola.prod.code.seat.cloud.vwgroup.com/v1/vehicles/{vin}/access/lock'
1340
1359
  elif command_arguments['command'] == LockUnlockCommand.Command.UNLOCK:
@@ -1342,19 +1361,23 @@ class Connector(BaseConnector):
1342
1361
  else:
1343
1362
  raise CommandError(f'Unknown command {command_arguments["command"]}')
1344
1363
  try:
1345
- command_response: requests.Response = self.session.post(url, data=json.dumps(command_dict), allow_redirects=True)
1364
+ headers = self.session.headers.copy()
1365
+ headers['SecToken'] = sec_token
1366
+ command_response: requests.Response = self.session.post(url, data=json.dumps(command_dict), allow_redirects=True, headers=headers)
1346
1367
  if command_response.status_code != requests.codes['ok']:
1347
1368
  LOG.error('Could not execute locking command (%s: %s)', command_response.status_code, command_response.text)
1348
1369
  raise CommandError(f'Could not execute locking command ({command_response.status_code}: {command_response.text})')
1349
1370
  except requests.exceptions.ConnectionError as connection_error:
1350
1371
  raise CommandError(f'Connection error: {connection_error}.'
1351
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1372
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1352
1373
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1353
1374
  raise CommandError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1354
1375
  except requests.exceptions.ReadTimeout as timeout_error:
1355
1376
  raise CommandError(f'Timeout during read: {timeout_error}') from timeout_error
1356
1377
  except requests.exceptions.RetryError as retry_error:
1357
1378
  raise CommandError(f'Retrying failed: {retry_error}') from retry_error
1379
+ except AuthenticationError as auth_error:
1380
+ raise CommandError(f'Authentication error: {auth_error}') from auth_error
1358
1381
  return command_arguments
1359
1382
 
1360
1383
  def __on_air_conditioning_settings_change(self, attribute: GenericAttribute, value: Any) -> Any:
@@ -1397,7 +1420,7 @@ class Connector(BaseConnector):
1397
1420
  raise SetterError(f'Could not set value ({settings_response.status_code}): {settings_response.text}')
1398
1421
  except requests.exceptions.ConnectionError as connection_error:
1399
1422
  raise SetterError(f'Connection error: {connection_error}.'
1400
- ' If this happens frequently, please check if other applications communicate with the Skoda server.') from connection_error
1423
+ ' If this happens frequently, please check if other applications communicate with the Seat/Cupra server.') from connection_error
1401
1424
  except requests.exceptions.ChunkedEncodingError as chunked_encoding_error:
1402
1425
  raise SetterError(f'Error: {chunked_encoding_error}') from chunked_encoding_error
1403
1426
  except requests.exceptions.ReadTimeout as timeout_error: