pycupra 0.1.4__py3-none-any.whl → 0.1.5__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.
pycupra/__version__.py CHANGED
@@ -3,4 +3,4 @@ pycupra - A Python 3 library for interacting with the My Cupra/My Seat portal.
3
3
 
4
4
  For more details and documentation, visit the github page at https://github.com/WulfgarW/pycupra
5
5
  """
6
- __version__ = "0.1.4"
6
+ __version__ = "0.1.5"
pycupra/connection.py CHANGED
@@ -1151,10 +1151,11 @@ class Connection:
1151
1151
  _LOGGER.warning(f'Could not fetch departure profiles, error: {error}')
1152
1152
  return False
1153
1153
 
1154
- async def getClimater(self, vin, baseurl):
1154
+ async def getClimater(self, vin, baseurl, oldClimatingData):
1155
1155
  """Get climatisation data."""
1156
- data={}
1157
- data['climater']={}
1156
+ #data={}
1157
+ #data['climater']={}
1158
+ data = {'climater': oldClimatingData}
1158
1159
  await self.set_token(self._session_auth_brand)
1159
1160
  try:
1160
1161
  response = await self.get(eval(f"f'{API_CLIMATER_STATUS}'"))
@@ -1180,12 +1181,14 @@ class Connection:
1180
1181
  return False
1181
1182
  return data
1182
1183
 
1183
- async def getCharger(self, vin, baseurl):
1184
+ async def getCharger(self, vin, baseurl, oldChargingData):
1184
1185
  """Get charger data."""
1185
1186
  await self.set_token(self._session_auth_brand)
1186
1187
  try:
1187
1188
  chargingStatus = {}
1188
1189
  chargingInfo = {}
1190
+ #chargingModes = {}
1191
+ #chargingProfiles = {}
1189
1192
  response = await self.get(eval(f"f'{API_CHARGING}/status'"))
1190
1193
  if response.get('battery', {}):
1191
1194
  chargingStatus = response
@@ -1207,16 +1210,30 @@ class Connection:
1207
1210
  _LOGGER.warning(f'Could not fetch charging modes, HTTP status code: {response.get("status_code")}')
1208
1211
  else:
1209
1212
  _LOGGER.info('Unhandled error while trying to fetch charging modes')"""
1210
- if chargingStatus != {} and chargingInfo != {}:
1211
- data = {'charging': {
1212
- 'status': chargingStatus,
1213
- 'info' : chargingInfo,
1214
- #'modes' : chargingModes,
1215
- }
1216
- }
1213
+ """response = await self.get(eval(f"f'{API_CHARGING}/profiles'"))
1214
+ if response.get('profiles', {}):
1215
+ chargingProfiles = response
1216
+ elif response.get('status_code', {}):
1217
+ _LOGGER.warning(f'Could not fetch charging profiles, HTTP status code: {response.get("status_code")}')
1218
+ else:
1219
+ _LOGGER.info('Unhandled error while trying to fetch charging profiles')"""
1220
+ data = {'charging': oldChargingData}
1221
+ if chargingStatus != {}:
1222
+ data['charging']['status'] = chargingStatus
1223
+ else:
1224
+ _LOGGER.warning(f'getCharger() got no valid data for charging status')
1225
+ if chargingInfo != {}:
1226
+ data['charging']['info'] = chargingInfo
1217
1227
  else:
1218
- _LOGGER.warning(f'getCharger() got no valid data. Returning None')
1219
- return None
1228
+ _LOGGER.warning(f'getCharger() got no valid data for charging info')
1229
+ #if chargingModes != {}:
1230
+ # data['charging']['modes'] = chargingModes
1231
+ #else:
1232
+ # _LOGGER.warning(f'getCharger() got no valid data for charging modes')
1233
+ #if chargingProfiles != {}:
1234
+ # data['charging']['profiles'] = chargingProfiles
1235
+ #else:
1236
+ # _LOGGER.warning(f'getCharger() got no valid data for charging profiles')
1220
1237
  return data
1221
1238
  except Exception as error:
1222
1239
  _LOGGER.warning(f'Could not fetch charger, error: {error}')
pycupra/dashboard.py CHANGED
@@ -453,6 +453,7 @@ class RequestRefresh(Switch):
453
453
  return self.vehicle.refresh_data
454
454
 
455
455
  async def turn_on(self):
456
+ _LOGGER.debug('User has called RequestRefresh().')
456
457
  await self.vehicle.set_refresh()
457
458
  await self.vehicle.update(updateType=1) #full update after set_refresh
458
459
  if self.callback is not None:
@@ -479,6 +480,7 @@ class RequestUpdate(Switch):
479
480
  return False #self.vehicle.update
480
481
 
481
482
  async def turn_on(self):
483
+ _LOGGER.debug('User has called RequestUpdate().')
482
484
  await self.vehicle.update(updateType=1) #full update after set_refresh
483
485
  if self.callback is not None:
484
486
  self.callback()
pycupra/vehicle.py CHANGED
@@ -76,6 +76,7 @@ class Vehicle:
76
76
  'vehicleHealthWarnings': {'active': False, 'reason': 'not supported'},
77
77
  'state': {'active': False, 'reason': 'not supported'},
78
78
  'charging': {'active': False, 'reason': 'not supported', 'supportsTargetStateOfCharge': False},
79
+ 'chargingProfiles': {'active': False, 'reason': 'not supported', "supportsTimerClimatisation": False,"supportsVehiclePositionedInProfileID": False,"supportsSingleTimer": False},
79
80
  'honkAndFlash': {'active': False, 'reason': 'not supported'},
80
81
  'parkingPosition': {'active': False, 'reason': 'not supported'},
81
82
  'departureTimers': {'active': False, 'reason': 'not supported', 'supportsSingleTimer': False},
@@ -121,6 +122,10 @@ class Vehicle:
121
122
  data['supportsTargetStateOfCharge']=True
122
123
  if capa['parameters'].get('supportsSingleTimer',False)==True or capa['parameters'].get('supportsSingleTimer',False)=='true':
123
124
  data['supportsSingleTimer']=True
125
+ if capa['parameters'].get('supportsVehiclePositionedInProfileID',False)==True or capa['parameters'].get('supportsVehiclePositionedInProfileID',False)=='true':
126
+ data['supportsVehiclePositionedInProfileID']=True
127
+ if capa['parameters'].get('supportsTimerClimatisation',False)==True or capa['parameters'].get('supportsTimerClimatisation',False)=='true':
128
+ data['supportsTimerClimatisation']=True
124
129
  self._relevantCapabilties[id].update(data)
125
130
 
126
131
 
@@ -245,7 +250,7 @@ class Vehicle:
245
250
  async def get_climater(self):
246
251
  """Fetch climater data if function is enabled."""
247
252
  if self._relevantCapabilties.get('climatisation', {}).get('active', False):
248
- data = await self._connection.getClimater(self.vin, self._apibase)
253
+ data = await self._connection.getClimater(self.vin, self._apibase, deepcopy(self.attrs.get('climater',{})))
249
254
  if data:
250
255
  self._states.update(data)
251
256
  self._last_get_climater = datetime.now(tz=None)
@@ -311,7 +316,7 @@ class Vehicle:
311
316
  async def get_charger(self):
312
317
  """Fetch charger data if function is enabled."""
313
318
  if self._relevantCapabilties.get('charging', {}).get('active', False):
314
- data = await self._connection.getCharger(self.vin, self._apibase)
319
+ data = await self._connection.getCharger(self.vin, self._apibase, deepcopy(self.attrs.get('charging',{})))
315
320
  if data:
316
321
  self._states.update(data)
317
322
  self._last_get_charger = datetime.now(tz=None)
@@ -396,6 +401,33 @@ class Vehicle:
396
401
  _LOGGER.error('No charger support.')
397
402
  raise SeatInvalidRequestException('No charger support.')
398
403
 
404
+ async def set_charger_target_soc(self, value):
405
+ """Set target state of charge"""
406
+ if self.is_charging_supported:
407
+ if isinstance(value, int):
408
+ if 1 <= int(value) <= 100:
409
+ # VW-Group API charger current request
410
+ if self._relevantCapabilties.get('charging', {}).get('active', False) and self._relevantCapabilties.get('charging', {}).get('supportsTargetStateOfCharge', False):
411
+ data= deepcopy(self.attrs.get('charging',{}).get('info',{}).get('settings',{}))
412
+ if data=={}:
413
+ _LOGGER.error(f'Can not set target soc, because currently no charging settings are present.')
414
+ raise SeatInvalidRequestException(f'Set target soc not possible. Charging settings not present.')
415
+ data['targetSoc'] = int(value)
416
+ else:
417
+ _LOGGER.warning(f'Can not set target soc, because vehicle does not support this feature.')
418
+ return False
419
+ else:
420
+ _LOGGER.error(f'Set target soc to {value} is not supported.')
421
+ raise SeatInvalidRequestException(f'Set target soc to {value} is not supported.')
422
+ # Mimick app and set charger max ampere to Maximum/Reduced
423
+ else:
424
+ _LOGGER.error(f'Data type passed is invalid.')
425
+ raise SeatInvalidRequestException(f'Invalid data type.')
426
+ return await self.set_charger('settings', data)
427
+ else:
428
+ _LOGGER.error('No charger support.')
429
+ raise SeatInvalidRequestException('No charger support.')
430
+
399
431
  async def set_charger(self, action, data=None):
400
432
  """Charging actions."""
401
433
  if not self._relevantCapabilties.get('charging', {}).get('active', False):
@@ -450,9 +482,11 @@ class Vehicle:
450
482
  if not self.charging:
451
483
  actionSuccessful = True
452
484
  elif mode == 'settings':
485
+ if data.get('targetSoc',0) == self.target_soc: # In case targetSoc is changed
486
+ actionSuccessful = True
453
487
  if data.get('maxChargeCurrentAc','') == self.charge_max_ampere: # In case 'maximum', 'reduced'
454
488
  actionSuccessful = True
455
- if data.get('maxChargeCurrentAcInAmperes',0) == self.charge_max_ampere: # In case of a numerical value
489
+ if data.get('maxChargeCurrentAcInAmperes',0) == self.charge_max_ampere: # In case of a numerical value for charge current
456
490
  actionSuccessful = True
457
491
  else:
458
492
  _LOGGER.error(f'Missing code in vehicle._set_charger() for mode {mode}')
@@ -3150,7 +3184,7 @@ class Vehicle:
3150
3184
  self.storeFirebaseNotifications(obj, notification, data_message)
3151
3185
 
3152
3186
  if self.firebaseStatus != FIREBASE_STATUS_ACTIVATED:
3153
- _LOGGER.info(f'While firebase is not fully activated, received notifications are just acknoledged.')
3187
+ _LOGGER.info(f'While firebase is not fully activated, received notifications are just acknowledged.')
3154
3188
  # As long as the firebase status is not set to activated, ignore the notifications
3155
3189
  return False
3156
3190
 
@@ -3200,7 +3234,7 @@ class Vehicle:
3200
3234
  await self.get_departure_profiles()
3201
3235
  if self.updateCallback:
3202
3236
  await self.updateCallback(2)
3203
- elif type in ('charging-status-changed', 'charging-started', 'charging-stopped'):
3237
+ elif type in ('charging-status-changed', 'charging-started', 'charging-stopped', 'charging-settings-updated'):
3204
3238
  if self._requests.get('batterycharge', {}).get('id', None):
3205
3239
  openRequest= self._requests.get('batterycharge', {}).get('id', None)
3206
3240
  if openRequest == requestId:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: A library to read and send vehicle data via Cupra/Seat portal using the same API calls as the MyCupra/MySeat mobile app.
5
5
  Home-page: https://github.com/WulfgarW/pycupra
6
6
  Author: WulfgarW
@@ -1,12 +1,12 @@
1
1
  pycupra/__init__.py,sha256=p0880jPkLqOErX3u3qaLboBLOsEHFpe44axApdaGeqI,231
2
- pycupra/__version__.py,sha256=eKzk7G69_LtPVYjNt3lX5LnPJXkUoj0G0EKvXxByrlA,207
3
- pycupra/connection.py,sha256=r02CHAhRrZwu90AIsfTnzAhRn9dZjK8WuZvhUa6_DcA,85314
2
+ pycupra/__version__.py,sha256=y2dos0x1TDMyh80ZOW3YvhHvw1DWdxYSgYNyRSzioPY,207
3
+ pycupra/connection.py,sha256=VPyLBfcmWPm4L8cL5HXvFT179PhNmiDn3yvWiNtu3Pw,86366
4
4
  pycupra/const.py,sha256=cJJ9xrof6HZ7ZE7nXnB6tU4qMbSadlN8mgs43Igy7Mo,10591
5
- pycupra/dashboard.py,sha256=hFHhCDrCNufQR1I85AlR4kPgSlFSinCegZ0w8F4FvUk,43703
5
+ pycupra/dashboard.py,sha256=RlJPdTvJV7Urog5gCz_4pYWNd5_ApQIVJUCwJIi_7L8,43822
6
6
  pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
7
7
  pycupra/firebase.py,sha256=V3Ico6FZzEn0-5-CnqaDP9Mg9LpVU-_qLyZQwiRBbD0,2725
8
8
  pycupra/utilities.py,sha256=cH4MiIzT2WlHgmnl_E7rR0R5LvCXfDNvirJolct50V8,2563
9
- pycupra/vehicle.py,sha256=armeMQHxOZyyQJ9Iu7G26pq_BNc8oahPFxOe7daEip8,151994
9
+ pycupra/vehicle.py,sha256=yMaO-6lquak8821usCen6LWEM7rn0EZjiEOzK9jp6e4,154682
10
10
  pycupra/firebase_messaging/__init__.py,sha256=oerLHWvEf4qRqu3GxSX6SLY_OYI430ydAiAhKtzyMEM,666
11
11
  pycupra/firebase_messaging/android_checkin_pb2.py,sha256=-U1oGroFt3KRuGDieae3iTcux6mAfx1TFkE1Q35ul2E,2849
12
12
  pycupra/firebase_messaging/android_checkin_pb2.pyi,sha256=7KL-zQIz2Zz7uftcLkv57Podzu-yk6trn50FN4X4A8E,9379
@@ -18,8 +18,8 @@ pycupra/firebase_messaging/fcmregister.py,sha256=yZngC-0ZfTygtjfdzg03OW_3xk2n_uS
18
18
  pycupra/firebase_messaging/mcs_pb2.py,sha256=nwXY7IDgLYPxgpSGs6wyTSyYDdomQsyGqH8R8EgODLg,7733
19
19
  pycupra/firebase_messaging/mcs_pb2.pyi,sha256=HfIhInC3wRg8_caKwUm-V3knE2jTdEQvBy6uXgQ5rHY,33959
20
20
  pycupra/firebase_messaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- pycupra-0.1.4.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
22
- pycupra-0.1.4.dist-info/METADATA,sha256=zuQir0nJmXg_oS0xpQKEhyjL1Ub7rghOayNvNPSZvpU,3757
23
- pycupra-0.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
24
- pycupra-0.1.4.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
25
- pycupra-0.1.4.dist-info/RECORD,,
21
+ pycupra-0.1.5.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
22
+ pycupra-0.1.5.dist-info/METADATA,sha256=upt06crj4Naaogz_wPgfmLUDZ8VXdwDlZLzP9bthKpM,3757
23
+ pycupra-0.1.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
24
+ pycupra-0.1.5.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
25
+ pycupra-0.1.5.dist-info/RECORD,,