pycupra 0.1.9__py3-none-any.whl → 0.1.11__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.9"
6
+ __version__ = "0.1.11"
pycupra/connection.py CHANGED
@@ -839,7 +839,12 @@ class Connection:
839
839
  if response.get('capabilities', False):
840
840
  vehicle["capabilities"]=response.get('capabilities')
841
841
  else:
842
- _LOGGER.warning(f"Failed to aquire capabilities information about vehicle with VIN {vehicle}")
842
+ _LOGGER.warning(f"Failed to aquire capabilities information about vehicle with VIN {vehicle}.")
843
+ if vehicle.get('capabilities',None)!=None:
844
+ _LOGGER.warning(f"Keeping the old capability information.")
845
+ else:
846
+ _LOGGER.warning(f"Initialising vehicle without capabilities.")
847
+ vehicle["capabilities"]=[]
843
848
  response = await self.get(eval(f"f'{API_CONNECTION}'"))
844
849
  #self._session_headers['Accept'] = 'application/json'
845
850
  if response.get('connection', False):
pycupra/dashboard.py CHANGED
@@ -1286,7 +1286,7 @@ def create_instruments():
1286
1286
  ),
1287
1287
  Sensor(
1288
1288
  attr="trip_last_cycle_average_electric_consumption",
1289
- name="Last cycle_average electric consumption",
1289
+ name="Last cycle average electric consumption",
1290
1290
  icon="mdi:car-battery",
1291
1291
  unit="kWh/100km",
1292
1292
  device_class="energy_distance"
pycupra/vehicle.py CHANGED
@@ -107,29 +107,33 @@ class Vehicle:
107
107
  # return_exceptions=True
108
108
  #)
109
109
  # Extract information of relevant capabilities
110
- for capa in self._capabilities:
111
- id=capa.get('id', '')
112
- if self._relevantCapabilties.get(id, False):
113
- data={}
114
- data['active']=capa.get('active', False)
115
- if capa.get('user-enabled', False):
116
- data['reason']='user-enabled'
117
- else:
118
- data['reason']=capa.get('user-enabled', False)
119
- if capa.get('status', False):
120
- data['reason']=capa.get('status', '')
121
- if capa.get('parameters', False):
122
- if capa['parameters'].get('supportsCyclicTrips',False)==True or capa['parameters'].get('supportsCyclicTrips',False)=='true':
123
- data['supportsCyclicTrips']=True
124
- if capa['parameters'].get('supportsTargetStateOfCharge',False)==True or capa['parameters'].get('supportsTargetStateOfCharge',False)=='true':
125
- data['supportsTargetStateOfCharge']=True
126
- if capa['parameters'].get('supportsSingleTimer',False)==True or capa['parameters'].get('supportsSingleTimer',False)=='true':
127
- data['supportsSingleTimer']=True
128
- if capa['parameters'].get('supportsVehiclePositionedInProfileID',False)==True or capa['parameters'].get('supportsVehiclePositionedInProfileID',False)=='true':
129
- data['supportsVehiclePositionedInProfileID']=True
130
- if capa['parameters'].get('supportsTimerClimatisation',False)==True or capa['parameters'].get('supportsTimerClimatisation',False)=='true':
131
- data['supportsTimerClimatisation']=True
132
- self._relevantCapabilties[id].update(data)
110
+ if self._capabilities != None:
111
+ for capa in self._capabilities:
112
+ id=capa.get('id', '')
113
+ if self._relevantCapabilties.get(id, False):
114
+ data={}
115
+ data['active']=capa.get('active', False)
116
+ if capa.get('user-enabled', False):
117
+ data['reason']='user-enabled'
118
+ else:
119
+ data['reason']=capa.get('user-enabled', False)
120
+ if capa.get('status', False):
121
+ data['reason']=capa.get('status', '')
122
+ if capa.get('parameters', False):
123
+ if capa['parameters'].get('supportsCyclicTrips',False)==True or capa['parameters'].get('supportsCyclicTrips',False)=='true':
124
+ data['supportsCyclicTrips']=True
125
+ if capa['parameters'].get('supportsTargetStateOfCharge',False)==True or capa['parameters'].get('supportsTargetStateOfCharge',False)=='true':
126
+ data['supportsTargetStateOfCharge']=True
127
+ if capa['parameters'].get('supportsSingleTimer',False)==True or capa['parameters'].get('supportsSingleTimer',False)=='true':
128
+ data['supportsSingleTimer']=True
129
+ if capa['parameters'].get('supportsVehiclePositionedInProfileID',False)==True or capa['parameters'].get('supportsVehiclePositionedInProfileID',False)=='true':
130
+ data['supportsVehiclePositionedInProfileID']=True
131
+ if capa['parameters'].get('supportsTimerClimatisation',False)==True or capa['parameters'].get('supportsTimerClimatisation',False)=='true':
132
+ data['supportsTimerClimatisation']=True
133
+ self._relevantCapabilties[id].update(data)
134
+ else:
135
+ _LOGGER.warning(f"No capabilities information stored for vehicle with VIN {self.vin}")
136
+
133
137
 
134
138
 
135
139
 
@@ -1309,7 +1313,7 @@ class Vehicle:
1309
1313
  _LOGGER.info('Remote honk and flash is not supported.')
1310
1314
  raise SeatInvalidRequestException('Remote honk and flash is not supported.')
1311
1315
  if self._requests['honkandflash'].get('id', False):
1312
- timestamp = self._requests.get('honkandflash', {}).get('timestamp', datetime.now() - timedelta(minutes=5))
1316
+ timestamp = self._requests.get('honkandflash', {}).get('timestamp', datetime.now() - timedelta(minutes=2))
1313
1317
  expired = datetime.now() - timedelta(minutes=1)
1314
1318
  if expired > timestamp:
1315
1319
  self._requests.get('honkandflash', {}).pop('id')
@@ -3335,6 +3339,10 @@ class Vehicle:
3335
3339
  #await self.get_statusreport() # Call not needed because it's part of updateCallback(2)
3336
3340
  if self.updateCallback:
3337
3341
  await self.updateCallback(2)
3342
+ else:
3343
+ _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last update of status report was at {self._last_get_statusreport}. So no need to update.')
3344
+ # Wait 2 seconds
3345
+ await asyncio.sleep(2)
3338
3346
  elif type == 'departure-times-updated':
3339
3347
  if self._requests.get('departuretimer', {}).get('id', None):
3340
3348
  openRequest= self._requests.get('departuretimer', {}).get('id', None)
@@ -3346,6 +3354,10 @@ class Vehicle:
3346
3354
  await self.get_departure_timers()
3347
3355
  if self.updateCallback:
3348
3356
  await self.updateCallback(2)
3357
+ else:
3358
+ _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last update of departure timers was at {self._last_get_departure_timers}. So no need to update.')
3359
+ # Wait 5 seconds
3360
+ await asyncio.sleep(5)
3349
3361
  elif type == 'departure-profiles-updated': # !!! Is this the right type?
3350
3362
  if self._requests.get('departureprofile', {}).get('id', None):
3351
3363
  openRequest= self._requests.get('departureprofile', {}).get('id', None)
@@ -3357,6 +3369,10 @@ class Vehicle:
3357
3369
  await self.get_departure_profiles()
3358
3370
  if self.updateCallback:
3359
3371
  await self.updateCallback(2)
3372
+ else:
3373
+ _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last update of departure profiles was at {self._last_get_departure_profiles}. So no need to update.')
3374
+ # Wait 5 seconds
3375
+ await asyncio.sleep(5)
3360
3376
  elif type in ('charging-status-changed', 'charging-started', 'charging-stopped', 'charging-settings-updated'):
3361
3377
  if self._requests.get('batterycharge', {}).get('id', None):
3362
3378
  openRequest= self._requests.get('batterycharge', {}).get('id', None)
@@ -3370,6 +3386,8 @@ class Vehicle:
3370
3386
  await self.updateCallback(2)
3371
3387
  else:
3372
3388
  _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last get_charger was at {self._last_get_charger}. So no need to update.')
3389
+ # Wait 5 seconds
3390
+ await asyncio.sleep(5)
3373
3391
  elif type in ('climatisation-status-changed','climatisation-started', 'climatisation-stopped', 'climatisation-settings-updated'):
3374
3392
  if self._requests.get('climatisation', {}).get('id', None):
3375
3393
  openRequest= self._requests.get('climatisation', {}).get('id', None)
@@ -3383,6 +3401,8 @@ class Vehicle:
3383
3401
  await self.updateCallback(2)
3384
3402
  else:
3385
3403
  _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last get_climater was at {self._last_get_climater}. So no need to update.')
3404
+ # Wait 5 seconds
3405
+ await asyncio.sleep(5)
3386
3406
  elif type in ('vehicle-area-alarm-vehicle-exits-zone-triggered', 'vehicle-area-alarm-vehicle-enters-zone-triggered'):
3387
3407
  #if self._last_get_position < datetime.now(tz=None) - timedelta(seconds= 30):
3388
3408
  # # Update position data only if the last one is older than timedelta
@@ -3415,8 +3435,19 @@ class Vehicle:
3415
3435
  # Do full update only if the last one is older than timedelta or if the notification belongs to an open request initiated by PyCupra
3416
3436
  if self.updateCallback:
3417
3437
  await self.updateCallback(1)
3438
+ else:
3439
+ _LOGGER.debug(f'It is now {datetime.now(tz=None)}. Last full update was at {self._last_full_update}. So no need to update.')
3440
+ # Wait 5 seconds
3441
+ await asyncio.sleep(2)
3442
+ elif type == 'vehicle-honk-and-flash-started':
3443
+ if self._requests.get('refresh', {}).get('id', None):
3444
+ openRequest= self._requests.get('refresh', {}).get('id', None)
3445
+ if openRequest == requestId:
3446
+ _LOGGER.debug(f'The notification closes an open request initiated by PyCupra.')
3447
+ self._requests.get('refresh', {}).pop('id')
3448
+ # Nothing else to do
3418
3449
  elif type in ('vehicle-area-alert-added', 'vehicle-area-alert-updated'):
3419
3450
  _LOGGER.info(f' Intentionally ignoring a notification of type \'{type}\')')
3420
3451
  else:
3421
- _LOGGER.warning(f' Don\'t know what to do with a notification of type \'{type}\')')
3452
+ _LOGGER.warning(f' Don\'t know what to do with a notification of type \'{type}\'. Please open an issue.)')
3422
3453
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycupra
3
- Version: 0.1.9
3
+ Version: 0.1.11
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=dcxJ-u8Zz6qTGBXri5kGr0y8fa_8l43365hGXeOK-zU,207
3
- pycupra/connection.py,sha256=Knu3vzokMRrsg9psjeD_r-2cl04ySJ1j7Mrn2g9mzdg,92941
2
+ pycupra/__version__.py,sha256=CBIUvP7kBoPPjvk-0KBtBB_vkj1PUBBiezoLxmbQBps,208
3
+ pycupra/connection.py,sha256=-wfamvOPP0gDGo5Picd2zx9pHGs90vVqqCxp6SFn6PQ,93278
4
4
  pycupra/const.py,sha256=5b4uuNUE1AGZHmqQfIZv-76Ad20mJTXXQPGI8TU6FfY,10631
5
- pycupra/dashboard.py,sha256=AlffEx8WmhLaSwX-eVcrOc54rUmwpzZUuR1fhruYkzI,45337
5
+ pycupra/dashboard.py,sha256=_8qlVr1k_L3_7A7dDc9ugzpGK_Dg6UZgv_Pp-1pPaPE,45337
6
6
  pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
7
7
  pycupra/firebase.py,sha256=lmI4a8f5VAlmHAqP2OiJWZhn7dmhyHkIBxL252qdtkA,3454
8
8
  pycupra/utilities.py,sha256=6sDxWP13-XtxmqhuBJBGdVbkj48BQ9AxFMrBPxH0J7g,2679
9
- pycupra/vehicle.py,sha256=12pFVqgIRkPMJ9IoBt0TAuSS4RRQOdTCq4-ltNtbN9c,162376
9
+ pycupra/vehicle.py,sha256=svuZ9xabbHa67saOQ1yGJcB8WCxV3zJmp32LFl8f_kQ,164254
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.9.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
22
- pycupra-0.1.9.dist-info/METADATA,sha256=5LDPYAqO74WlAZanWVES__uzRngZlq2t_JS8cbABI9w,3757
23
- pycupra-0.1.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
24
- pycupra-0.1.9.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
25
- pycupra-0.1.9.dist-info/RECORD,,
21
+ pycupra-0.1.11.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
22
+ pycupra-0.1.11.dist-info/METADATA,sha256=Xh1CM38qBXwPXTUvOIUEXVOMKKP0DgB6jkMlGLEQngA,3758
23
+ pycupra-0.1.11.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
24
+ pycupra-0.1.11.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
25
+ pycupra-0.1.11.dist-info/RECORD,,