pycupra 0.1.6__py3-none-any.whl → 0.1.7__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 +1 -1
- pycupra/connection.py +18 -8
- pycupra/const.py +1 -0
- pycupra/dashboard.py +12 -0
- pycupra/firebase_messaging/fcmpushclient.py +14 -3
- pycupra/vehicle.py +18 -10
- {pycupra-0.1.6.dist-info → pycupra-0.1.7.dist-info}/METADATA +1 -1
- {pycupra-0.1.6.dist-info → pycupra-0.1.7.dist-info}/RECORD +11 -11
- {pycupra-0.1.6.dist-info → pycupra-0.1.7.dist-info}/WHEEL +0 -0
- {pycupra-0.1.6.dist-info → pycupra-0.1.7.dist-info}/licenses/LICENSE +0 -0
- {pycupra-0.1.6.dist-info → pycupra-0.1.7.dist-info}/top_level.txt +0 -0
pycupra/__version__.py
CHANGED
pycupra/connection.py
CHANGED
@@ -151,6 +151,7 @@ class Connection:
|
|
151
151
|
self.addToAnonymisationKeys('family_name')
|
152
152
|
self.addToAnonymisationKeys('birthdate')
|
153
153
|
self.addToAnonymisationKeys('vin')
|
154
|
+
self._error401 = False
|
154
155
|
|
155
156
|
|
156
157
|
def _clear_cookies(self):
|
@@ -596,22 +597,31 @@ class Connection:
|
|
596
597
|
'request_info': error.request_info
|
597
598
|
}
|
598
599
|
if error.status == 401:
|
599
|
-
_LOGGER.warning('Received "Unauthorized" while fetching data
|
600
|
+
_LOGGER.warning('Received "Unauthorized" while fetching data. This can occur if tokens expired or refresh service is unavailable.')
|
601
|
+
if self._error401 != True:
|
602
|
+
self._error401 = True
|
603
|
+
rc=await self.refresh_token(self._session_auth_brand)
|
604
|
+
if rc:
|
605
|
+
_LOGGER.info('Successfully refreshed tokens after error 401.')
|
606
|
+
self._error401 = False
|
607
|
+
#return True
|
608
|
+
else:
|
609
|
+
_LOGGER.info('Refresh of tokens after error 401 not successful.')
|
600
610
|
elif error.status == 400:
|
601
|
-
_LOGGER.error('Received "Bad Request" from server
|
611
|
+
_LOGGER.error('Received "Bad Request" from server. The request might be malformed or not implemented correctly for this vehicle.')
|
602
612
|
elif error.status == 412:
|
603
|
-
_LOGGER.debug('Received "Pre-condition failed"
|
613
|
+
_LOGGER.debug('Received "Pre-condition failed". Service might be temporarily unavailable.')
|
604
614
|
elif error.status == 500:
|
605
|
-
_LOGGER.info('Received "Internal server error"
|
615
|
+
_LOGGER.info('Received "Internal server error". The service is temporarily unavailable.')
|
606
616
|
elif error.status == 502:
|
607
|
-
_LOGGER.info('Received "Bad gateway"
|
617
|
+
_LOGGER.info('Received "Bad gateway". Either the endpoint is temporarily unavailable or not supported for this vehicle.')
|
608
618
|
elif 400 <= error.status <= 499:
|
609
619
|
_LOGGER.error('Received unhandled error indicating client-side problem.\nRestart or try again later.')
|
610
620
|
elif 500 <= error.status <= 599:
|
611
621
|
_LOGGER.error('Received unhandled error indicating server-side problem.\nThe service might be temporarily unavailable.')
|
612
622
|
else:
|
613
623
|
_LOGGER.error('Received unhandled error while requesting API endpoint.')
|
614
|
-
_LOGGER.debug(f'HTTP request information: {data}')
|
624
|
+
_LOGGER.debug(self.anonymise(f'HTTP request information: {data}'))
|
615
625
|
return data
|
616
626
|
except Exception as e:
|
617
627
|
_LOGGER.debug(f'Got non HTTP related error: {e}')
|
@@ -704,7 +714,7 @@ class Connection:
|
|
704
714
|
_LOGGER.debug(self.anonymise(f'Data call returned: {response}'))
|
705
715
|
return response
|
706
716
|
except aiohttp.client_exceptions.ClientResponseError as error:
|
707
|
-
_LOGGER.debug(f'Request failed. Data: {data}, HTTP request headers: {self._session_headers}')
|
717
|
+
_LOGGER.debug(self.anonymise(f'Request failed. Data: {data}, HTTP request headers: {self._session_headers}'))
|
708
718
|
if error.status == 401:
|
709
719
|
_LOGGER.error('Unauthorized')
|
710
720
|
elif error.status == 400:
|
@@ -1625,7 +1635,7 @@ class Connection:
|
|
1625
1635
|
if expires > now:
|
1626
1636
|
return expires
|
1627
1637
|
else:
|
1628
|
-
_LOGGER.debug(f'Token expired at {expires.strftime("%Y-%m-%d %H:%M:%S")}
|
1638
|
+
_LOGGER.debug(f'Token expired at {expires.strftime("%Y-%m-%d %H:%M:%S")}')
|
1629
1639
|
return False
|
1630
1640
|
except Exception as e:
|
1631
1641
|
_LOGGER.info(f'Token validation failed, {e}')
|
pycupra/const.py
CHANGED
pycupra/dashboard.py
CHANGED
@@ -755,6 +755,18 @@ class Warnings(Sensor):
|
|
755
755
|
def assumed_state(self):
|
756
756
|
return False
|
757
757
|
|
758
|
+
@property
|
759
|
+
def attributes(self):
|
760
|
+
attrs = {'warnings': 'No warnings'}
|
761
|
+
if self.vehicle.attrs.get('warninglights', {}).get('statuses',[]):
|
762
|
+
warningTextList = []
|
763
|
+
for elem in self.vehicle.attrs['warninglights']['statuses']:
|
764
|
+
if isinstance(elem, dict):
|
765
|
+
if elem.get('text',''):
|
766
|
+
warningTextList.append(elem.get('text',''))
|
767
|
+
attrs['warnings'] = warningTextList
|
768
|
+
return attrs
|
769
|
+
|
758
770
|
class DepartureTimer1(Switch):
|
759
771
|
def __init__(self):
|
760
772
|
super().__init__(attr="departure1", name="Departure timer 1", icon="mdi:radiator")
|
@@ -599,10 +599,21 @@ class FcmPushClient: # pylint:disable=too-many-instance-attributes
|
|
599
599
|
return
|
600
600
|
|
601
601
|
if isinstance(msg, DataMessageStanza):
|
602
|
-
await self._handle_data_message(msg)
|
603
|
-
self.persistent_ids.append(msg.persistent_id)
|
602
|
+
#await self._handle_data_message(msg)
|
603
|
+
#self.persistent_ids.append(msg.persistent_id)
|
604
|
+
#if self.config.send_selective_acknowledgements:
|
605
|
+
# await self._send_selective_ack(msg.persistent_id)
|
604
606
|
if self.config.send_selective_acknowledgements:
|
605
|
-
|
607
|
+
# As handle_data_message with the callback of onNotification can take some time, send_selective_ack is called in parallel
|
608
|
+
await asyncio.gather(
|
609
|
+
self._handle_data_message(msg),
|
610
|
+
self._send_selective_ack(msg.persistent_id),
|
611
|
+
return_exceptions=True
|
612
|
+
)
|
613
|
+
self.persistent_ids.append(msg.persistent_id),
|
614
|
+
else:
|
615
|
+
await self._handle_data_message(msg)
|
616
|
+
self.persistent_ids.append(msg.persistent_id)
|
606
617
|
elif isinstance(msg, HeartbeatPing):
|
607
618
|
await self._handle_ping(msg)
|
608
619
|
elif isinstance(msg, HeartbeatAck):
|
pycupra/vehicle.py
CHANGED
@@ -24,6 +24,7 @@ from .const import (
|
|
24
24
|
FIREBASE_STATUS_NOT_INITIALISED,
|
25
25
|
FIREBASE_STATUS_ACTIVATED,
|
26
26
|
FIREBASE_STATUS_ACTIVATION_FAILED,
|
27
|
+
FIREBASE_STATUS_ACTIVATION_STOPPED,
|
27
28
|
FIREBASE_STATUS_NOT_WANTED,
|
28
29
|
)
|
29
30
|
|
@@ -153,6 +154,11 @@ class Vehicle:
|
|
153
154
|
if not self.deactivated:
|
154
155
|
try:
|
155
156
|
if self.firebaseStatus == FIREBASE_STATUS_ACTIVATED:
|
157
|
+
# Check, if fcmpushclient still started
|
158
|
+
if not self.firebase._pushClient.is_started():
|
159
|
+
_LOGGER.warning(f'firebaseStatus={self.firebaseStatus}, but state of push client is not started. Changing firebaseStatus to {FIREBASE_STATUS_ACTIVATION_STOPPED}')
|
160
|
+
self.firebaseStatus = FIREBASE_STATUS_ACTIVATION_STOPPED
|
161
|
+
|
156
162
|
fullUpdateExpired = datetime.now(tz=None) - timedelta(seconds= 1700)
|
157
163
|
oldMileage = self.distance
|
158
164
|
if self._last_get_mileage < datetime.now(tz=None) - timedelta(seconds= 300):
|
@@ -192,6 +198,17 @@ class Vehicle:
|
|
192
198
|
if self.firebaseStatus != FIREBASE_STATUS_ACTIVATED:
|
193
199
|
await self.get_mileage()
|
194
200
|
|
201
|
+
if self.firebaseStatus == FIREBASE_STATUS_ACTIVATION_STOPPED:
|
202
|
+
# Trying to activate firebase connection again
|
203
|
+
await self.firebase._pushClient.start()
|
204
|
+
#await asyncio.sleep(5)
|
205
|
+
if self.firebase._pushClient.is_started():
|
206
|
+
self.firebaseStatus = FIREBASE_STATUS_ACTIVATED
|
207
|
+
_LOGGER.debug(f'Successfully restarted push client. New firebase status ={self.firebaseStatus}')
|
208
|
+
else:
|
209
|
+
_LOGGER.debug(f'Restart of push client failed. Firebase status ={self.firebaseStatus}')
|
210
|
+
|
211
|
+
|
195
212
|
await asyncio.gather(
|
196
213
|
#self.get_statusreport(),
|
197
214
|
self.get_charger(),
|
@@ -2236,14 +2253,7 @@ class Vehicle:
|
|
2236
2253
|
@property
|
2237
2254
|
def warnings(self):
|
2238
2255
|
"""Return warnings."""
|
2239
|
-
|
2240
|
-
warningTextList = []
|
2241
|
-
for elem in self.attrs['warninglights']['statuses']:
|
2242
|
-
if isinstance(elem, dict):
|
2243
|
-
if elem.get('text',''):
|
2244
|
-
warningTextList.append(elem.get('text',''))
|
2245
|
-
return warningTextList
|
2246
|
-
return 'No warnings'
|
2256
|
+
return len(self.attrs.get('warninglights', {}).get('statuses',[]))
|
2247
2257
|
|
2248
2258
|
@property
|
2249
2259
|
def is_warnings_supported(self):
|
@@ -3320,8 +3330,6 @@ class Vehicle:
|
|
3320
3330
|
else:
|
3321
3331
|
_LOGGER.warning(f' Don\'t know what to do with a notification of type \'{type}\')')
|
3322
3332
|
|
3323
|
-
|
3324
|
-
|
3325
3333
|
|
3326
3334
|
def storeFirebaseNotifications(self, obj, notification, data_message):
|
3327
3335
|
_LOGGER.debug(f'In storeFirebaseNotifications. notification={notification}')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pycupra
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
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,25 +1,25 @@
|
|
1
1
|
pycupra/__init__.py,sha256=p0880jPkLqOErX3u3qaLboBLOsEHFpe44axApdaGeqI,231
|
2
|
-
pycupra/__version__.py,sha256=
|
3
|
-
pycupra/connection.py,sha256=
|
4
|
-
pycupra/const.py,sha256=
|
5
|
-
pycupra/dashboard.py,sha256=
|
2
|
+
pycupra/__version__.py,sha256=DKM773a_0KC1VMvD1yaWYuzJUpp3XsxR_HcWB1g_-Ys,207
|
3
|
+
pycupra/connection.py,sha256=GWup_DcxnHNydb0DRJV79Hd108HJxMrGk89vi5R7meE,91150
|
4
|
+
pycupra/const.py,sha256=F6y3qt_wS1QxhdSR-NHxB7lpUcf5uKLeoeTAJcAXgsE,10630
|
5
|
+
pycupra/dashboard.py,sha256=xWggxTyKTBm3ByjRtymVzLJWtlIa52IEJsNx0z7bA9Q,44324
|
6
6
|
pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
|
7
7
|
pycupra/firebase.py,sha256=tuN_W3OX3h3-yfdprWzmCn6z_T-BMx-OpL7Z6hOA8Lc,3451
|
8
8
|
pycupra/utilities.py,sha256=6sDxWP13-XtxmqhuBJBGdVbkj48BQ9AxFMrBPxH0J7g,2679
|
9
|
-
pycupra/vehicle.py,sha256=
|
9
|
+
pycupra/vehicle.py,sha256=jOtpn8WUxKBYPIuCuPMfmH19AVfY0Mn1GXtRJM_gosQ,157941
|
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
|
13
13
|
pycupra/firebase_messaging/checkin_pb2.py,sha256=lFzCIAkYz9NFUpRbVuW-2kM_EaYKVWHeifHS1PV2eHQ,2795
|
14
14
|
pycupra/firebase_messaging/checkin_pb2.pyi,sha256=mHOqbedt5jZDI20jcyFrTMSnQ0f_tq4zkIlHiaSC3xI,14626
|
15
15
|
pycupra/firebase_messaging/const.py,sha256=XMy8kJ37uBSkTpVpdLeSjxk5UIPuvDuo-rxYdgmo2G8,1191
|
16
|
-
pycupra/firebase_messaging/fcmpushclient.py,sha256=
|
16
|
+
pycupra/firebase_messaging/fcmpushclient.py,sha256=7ADEYA6Aw4c42bwbIJr_I76wGiLOu99oV7PSNC4UcVs,30157
|
17
17
|
pycupra/firebase_messaging/fcmregister.py,sha256=yZngC-0ZfTygtjfdzg03OW_3xk2n_uSQQ3Lrash5Y_E,18091
|
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.
|
22
|
-
pycupra-0.1.
|
23
|
-
pycupra-0.1.
|
24
|
-
pycupra-0.1.
|
25
|
-
pycupra-0.1.
|
21
|
+
pycupra-0.1.7.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
22
|
+
pycupra-0.1.7.dist-info/METADATA,sha256=hQAjfqNAkgF72DsnoCrLL6NtkF5_iIWY8mgc4ssgsCo,3757
|
23
|
+
pycupra-0.1.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
24
|
+
pycupra-0.1.7.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
|
25
|
+
pycupra-0.1.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|