pycupra 0.1.8__py3-none-any.whl → 0.1.9__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 +14 -7
- pycupra/const.py +1 -1
- pycupra/dashboard.py +20 -17
- pycupra/firebase.py +3 -3
- pycupra/vehicle.py +8 -20
- {pycupra-0.1.8.dist-info → pycupra-0.1.9.dist-info}/METADATA +1 -1
- {pycupra-0.1.8.dist-info → pycupra-0.1.9.dist-info}/RECORD +11 -11
- {pycupra-0.1.8.dist-info → pycupra-0.1.9.dist-info}/WHEEL +0 -0
- {pycupra-0.1.8.dist-info → pycupra-0.1.9.dist-info}/licenses/LICENSE +0 -0
- {pycupra-0.1.8.dist-info → pycupra-0.1.9.dist-info}/top_level.txt +0 -0
pycupra/__version__.py
CHANGED
pycupra/connection.py
CHANGED
@@ -98,6 +98,7 @@ from .const import (
|
|
98
98
|
API_DESTINATION,
|
99
99
|
|
100
100
|
PUBLIC_MODEL_IMAGES_SERVER,
|
101
|
+
FIREBASE_STATUS_NOT_INITIALISED,
|
101
102
|
)
|
102
103
|
|
103
104
|
version_info >= (3, 0) or exit('Python 3 required')
|
@@ -109,14 +110,14 @@ TIMEOUT = timedelta(seconds=90)
|
|
109
110
|
class Connection:
|
110
111
|
""" Connection to Connect services """
|
111
112
|
# Init connection class
|
112
|
-
def __init__(self, session, brand='cupra', username='', password='', fulldebug=False, nightlyUpdateReduction=False, anonymise=True,
|
113
|
+
def __init__(self, session, brand='cupra', username='', password='', fulldebug=False, nightlyUpdateReduction=False, anonymise=True, tripStatisticsStartDate=None, **optional):
|
113
114
|
""" Initialize """
|
114
115
|
self._session = session
|
115
116
|
self._lock = asyncio.Lock()
|
116
117
|
self._session_fulldebug = fulldebug
|
117
118
|
self._session_nightlyUpdateReduction = nightlyUpdateReduction
|
118
119
|
self._session_anonymise = anonymise
|
119
|
-
self.
|
120
|
+
self._session_tripStatisticsStartDate = tripStatisticsStartDate
|
120
121
|
self._session_headers = HEADERS_SESSION.get(brand).copy()
|
121
122
|
self._session_base = BASE_SESSION
|
122
123
|
self._session_auth_headers = HEADERS_AUTH.copy()
|
@@ -561,8 +562,10 @@ class Connection:
|
|
561
562
|
for v in self.vehicles:
|
562
563
|
_LOGGER.debug(self.anonymise(f'Calling stopFirebase() for vehicle {v.vin}'))
|
563
564
|
newStatus = await v.stopFirebase()
|
564
|
-
if newStatus !=
|
565
|
+
if newStatus != FIREBASE_STATUS_NOT_INITIALISED:
|
565
566
|
_LOGGER.debug(self.anonymise(f'stopFirebase() not successful for vehicle {v.vin}'))
|
567
|
+
# Although stopFirebase() was not successful, the firebase status is reset to FIREBASE_STATUS_NOT_INITIALISED to allow a new initialisation
|
568
|
+
v.firebaseStatus = FIREBASE_STATUS_NOT_INITIALISED
|
566
569
|
await self.logout()
|
567
570
|
|
568
571
|
async def logout(self):
|
@@ -1089,12 +1092,12 @@ class Connection:
|
|
1089
1092
|
async def getTripStatistics(self, vin, baseurl, supportsCyclicTrips):
|
1090
1093
|
"""Get short term and cyclic trip statistics."""
|
1091
1094
|
await self.set_token(self._session_auth_brand)
|
1092
|
-
if self.
|
1093
|
-
# If connection was not initialised with parameter
|
1095
|
+
if self._session_tripStatisticsStartDate==None:
|
1096
|
+
# If connection was not initialised with parameter tripStatisticsStartDate, then 360 day is used for the CYCLIC trips and 90 days for the SHORT trips
|
1094
1097
|
# (This keeps the statistics shorter in Home Assistant)
|
1095
|
-
|
1098
|
+
startDate = (datetime.now() - timedelta(days= 360)).strftime('%Y-%m-%d')
|
1096
1099
|
else:
|
1097
|
-
|
1100
|
+
startDate = self._session_tripStatisticsStartDate
|
1098
1101
|
try:
|
1099
1102
|
data={'tripstatistics': {}}
|
1100
1103
|
if supportsCyclicTrips:
|
@@ -1109,6 +1112,10 @@ class Connection:
|
|
1109
1112
|
else:
|
1110
1113
|
_LOGGER.info(f'Vehicle does not support cyclic trips.')
|
1111
1114
|
dataType='SHORT'
|
1115
|
+
if self._session_tripStatisticsStartDate==None:
|
1116
|
+
# If connection was not initialised with parameter tripStatisticsStartDate, then 360 day is used for the CYCLIC trips and 90 days for the SHORT trips
|
1117
|
+
# (This keeps the statistics shorter in Home Assistant)
|
1118
|
+
startDate = (datetime.now() - timedelta(days= 90)).strftime('%Y-%m-%d')
|
1112
1119
|
response = await self.get(eval(f"f'{API_TRIP}'"))
|
1113
1120
|
if response.get('data', []):
|
1114
1121
|
data['tripstatistics']['short']= response.get('data', [])
|
pycupra/const.py
CHANGED
@@ -138,7 +138,7 @@ API_DEPARTURE_TIMERS = '{baseurl}/v1/vehicles/{vin}/departure-timers'
|
|
138
138
|
API_DEPARTURE_PROFILES = '{baseurl}/v1/vehicles/{vin}/departure/profiles' # Departure profiles
|
139
139
|
API_POSITION = '{baseurl}/v1/vehicles/{vin}/parkingposition' # Position data
|
140
140
|
API_POS_TO_ADDRESS= 'https://maps.googleapis.com/maps/api/directions/json?origin={lat},{lon}&destination={lat},{lon}&traffic_model=best_guess&departure_time=now&language=de&key={apiKeyForGoogle}&mode=driving'
|
141
|
-
API_TRIP = '{baseurl}/v1/vehicles/{vin}/driving-data/{dataType}?from={
|
141
|
+
API_TRIP = '{baseurl}/v1/vehicles/{vin}/driving-data/{dataType}?from={startDate}T00:00:00Z&to=2099-12-31T09:59:01Z' # Trip statistics (whole history) SHORT/LONG/CYCLIC (WEEK only with from)
|
142
142
|
API_MILEAGE = '{baseurl}/v1/vehicles/{vin}/mileage' # Total km etc
|
143
143
|
API_MAINTENANCE = '{baseurl}/v1/vehicles/{vin}/maintenance' # Inspection information
|
144
144
|
API_MEASUREMENTS = '{baseurl}/v1/vehicles/{vin}/measurements/engines' # ???
|
pycupra/dashboard.py
CHANGED
@@ -455,7 +455,7 @@ class RequestRefresh(Switch):
|
|
455
455
|
async def turn_on(self):
|
456
456
|
_LOGGER.debug('User has called RequestRefresh().')
|
457
457
|
await self.vehicle.set_refresh()
|
458
|
-
await self.vehicle.update(updateType=1) #full update after set_refresh
|
458
|
+
#await self.vehicle.update(updateType=1) #full update after set_refresh
|
459
459
|
if self.callback is not None:
|
460
460
|
self.callback()
|
461
461
|
|
@@ -776,11 +776,12 @@ class DepartureTimer1(Switch):
|
|
776
776
|
|
777
777
|
@property
|
778
778
|
def state(self):
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
779
|
+
if self.vehicle.departure1 != None:
|
780
|
+
status = self.vehicle.departure1.get("enabled", "")
|
781
|
+
if status:
|
782
|
+
return True
|
783
|
+
#else:
|
784
|
+
return False
|
784
785
|
|
785
786
|
async def turn_on(self):
|
786
787
|
await self.vehicle.set_timer_active(id=1, action="on")
|
@@ -808,11 +809,12 @@ class DepartureTimer2(Switch):
|
|
808
809
|
|
809
810
|
@property
|
810
811
|
def state(self):
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
812
|
+
if self.vehicle.departure2 != None:
|
813
|
+
status = self.vehicle.departure2.get("enabled", "")
|
814
|
+
if status:
|
815
|
+
return True
|
816
|
+
#else:
|
817
|
+
return False
|
816
818
|
|
817
819
|
async def turn_on(self):
|
818
820
|
await self.vehicle.set_timer_active(id=2, action="on")
|
@@ -839,11 +841,12 @@ class DepartureTimer3(Switch):
|
|
839
841
|
|
840
842
|
@property
|
841
843
|
def state(self):
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
844
|
+
if self.vehicle.departure3 != None:
|
845
|
+
status = self.vehicle.departure3.get("enabled", "")
|
846
|
+
if status:
|
847
|
+
return True
|
848
|
+
#else:
|
849
|
+
return False
|
847
850
|
|
848
851
|
async def turn_on(self):
|
849
852
|
await self.vehicle.set_timer_active(id=3, action="on")
|
@@ -1004,7 +1007,7 @@ class ChargingState(BinarySensor):
|
|
1004
1007
|
|
1005
1008
|
class AreaAlarm(BinarySensor):
|
1006
1009
|
def __init__(self):
|
1007
|
-
super().__init__(attr="area_alarm", name="Area alarm", icon="mdi:alarm-light", device_class=
|
1010
|
+
super().__init__(attr="area_alarm", name="Area alarm", icon="mdi:alarm-light", device_class=None)
|
1008
1011
|
|
1009
1012
|
@property
|
1010
1013
|
def state(self):
|
pycupra/firebase.py
CHANGED
@@ -43,7 +43,7 @@ class Firebase():
|
|
43
43
|
await asyncio.sleep(5)
|
44
44
|
return self._pushClient.is_started()
|
45
45
|
except Exception as e:
|
46
|
-
_LOGGER.error('Error in firebaseStart. Error: {e}')
|
46
|
+
_LOGGER.error(f'Error in firebaseStart. Error: {e}')
|
47
47
|
return False
|
48
48
|
|
49
49
|
async def firebaseStop(self):
|
@@ -54,7 +54,7 @@ class Firebase():
|
|
54
54
|
self._pushClient = None
|
55
55
|
return True
|
56
56
|
except Exception as e:
|
57
|
-
_LOGGER.error('Error in firebaseStop. Error: {e}')
|
57
|
+
_LOGGER.error(f'Error in firebaseStop. Error: {e}')
|
58
58
|
return False
|
59
59
|
|
60
60
|
def readFCMCredsFile(credsFile):
|
@@ -70,7 +70,7 @@ def readFCMCredsFile(credsFile):
|
|
70
70
|
_LOGGER.debug(f'{credsFile} not found.')
|
71
71
|
return {}
|
72
72
|
except Exception as e:
|
73
|
-
_LOGGER.warning('readFCMCredsFile() not successful. Error: {e}')
|
73
|
+
_LOGGER.warning(f'readFCMCredsFile() not successful. Error: {e}')
|
74
74
|
return ''
|
75
75
|
|
76
76
|
def writeFCMCredsFile(creds, firebaseCredentialsFileName):
|
pycupra/vehicle.py
CHANGED
@@ -188,6 +188,8 @@ class Vehicle:
|
|
188
188
|
newStatus = await self.stopFirebase()
|
189
189
|
if newStatus != FIREBASE_STATUS_NOT_INITIALISED:
|
190
190
|
_LOGGER.debug(f'stopFirebase() not successful.')
|
191
|
+
# Although stopFirebase() was not successful, the firebase status is reset to FIREBASE_STATUS_NOT_INITIALISED to allow a new initialisation
|
192
|
+
self.firebaseStatus = FIREBASE_STATUS_NOT_INITIALISED
|
191
193
|
newStatus = await self.initialiseFirebase(self._firebaseCredentialsFileName, self.updateCallback)
|
192
194
|
if newStatus == FIREBASE_STATUS_ACTIVATED:
|
193
195
|
_LOGGER.debug(f'Reinitialisation of firebase successful.New firebase status={self.firebaseStatus}.')
|
@@ -1384,6 +1386,11 @@ class Vehicle:
|
|
1384
1386
|
'status': response.get('status', 'Unknown'),
|
1385
1387
|
'id': response.get('id', 0)
|
1386
1388
|
}
|
1389
|
+
# if firebaseStatus is FIREBASE_STATUS_ACTIVATED, the request is assumed successful. Waiting for push notification before rereading status
|
1390
|
+
if self.firebaseStatus == FIREBASE_STATUS_ACTIVATED:
|
1391
|
+
_LOGGER.debug('POST request for wakeup vehicle assumed successful. Waiting for push notification')
|
1392
|
+
return True
|
1393
|
+
await self.update(updateType=1) #full update after set_refresh
|
1387
1394
|
return True
|
1388
1395
|
except(SeatInvalidRequestException, SeatException):
|
1389
1396
|
raise
|
@@ -3291,10 +3298,6 @@ class Vehicle:
|
|
3291
3298
|
_LOGGER.debug(f'Received push notification: notification id={notification}, type={obj.get('data',{}).get('type','')}, requestId={obj.get('data',{}).get('requestId','[None]')}')
|
3292
3299
|
_LOGGER.debug(f' data_message={data_message}, payload={obj.get('data',{}).get('payload','[None]')}')
|
3293
3300
|
|
3294
|
-
#temporary output of notifications in a file, will be removed in the next release
|
3295
|
-
#if self.updateCallback == self.update:
|
3296
|
-
# self.storeFirebaseNotifications(obj, notification, data_message)
|
3297
|
-
|
3298
3301
|
if self.firebaseStatus != FIREBASE_STATUS_ACTIVATED:
|
3299
3302
|
if self.firebaseStatus != FIREBASE_STATUS_ACTIVATION_STOPPED:
|
3300
3303
|
_LOGGER.info(f'While firebase is not fully activated, received notifications are just acknowledged.')
|
@@ -3402,7 +3405,7 @@ class Vehicle:
|
|
3402
3405
|
self._states.update(areaAlarm)
|
3403
3406
|
if self.updateCallback:
|
3404
3407
|
await self.updateCallback(2)
|
3405
|
-
elif type
|
3408
|
+
elif type in ('vehicle-wake-up-succeeded', 'vehicle-wakeup-succeeded'):
|
3406
3409
|
if self._requests.get('refresh', {}).get('id', None):
|
3407
3410
|
openRequest= self._requests.get('refresh', {}).get('id', None)
|
3408
3411
|
if openRequest == requestId:
|
@@ -3417,18 +3420,3 @@ class Vehicle:
|
|
3417
3420
|
else:
|
3418
3421
|
_LOGGER.warning(f' Don\'t know what to do with a notification of type \'{type}\')')
|
3419
3422
|
|
3420
|
-
|
3421
|
-
#temporary output of notifications in a file, will be removed in the next release
|
3422
|
-
#def storeFirebaseNotifications(self, obj, notification, data_message):
|
3423
|
-
# _LOGGER.debug(f'In storeFirebaseNotifications. notification={notification}')
|
3424
|
-
# fName = self._firebaseCredentialsFileName
|
3425
|
-
# fName = fName.replace('pycupra_firebase_credentials.json', 'pycupra_firebasenotifications.txt')
|
3426
|
-
|
3427
|
-
# with open(fName, "a") as ofile:
|
3428
|
-
# ofile.write(f'{datetime.now()}\n')
|
3429
|
-
# ofile.write(f' notification id={notification}, data_message={data_message}\n')
|
3430
|
-
# ofile.write(f' obj={obj}\n')
|
3431
|
-
# ofile.write("----------------------------------------------------------------\n")
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pycupra
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.9
|
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=
|
3
|
-
pycupra/connection.py,sha256=
|
4
|
-
pycupra/const.py,sha256=
|
5
|
-
pycupra/dashboard.py,sha256=
|
2
|
+
pycupra/__version__.py,sha256=dcxJ-u8Zz6qTGBXri5kGr0y8fa_8l43365hGXeOK-zU,207
|
3
|
+
pycupra/connection.py,sha256=Knu3vzokMRrsg9psjeD_r-2cl04ySJ1j7Mrn2g9mzdg,92941
|
4
|
+
pycupra/const.py,sha256=5b4uuNUE1AGZHmqQfIZv-76Ad20mJTXXQPGI8TU6FfY,10631
|
5
|
+
pycupra/dashboard.py,sha256=AlffEx8WmhLaSwX-eVcrOc54rUmwpzZUuR1fhruYkzI,45337
|
6
6
|
pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
|
7
|
-
pycupra/firebase.py,sha256=
|
7
|
+
pycupra/firebase.py,sha256=lmI4a8f5VAlmHAqP2OiJWZhn7dmhyHkIBxL252qdtkA,3454
|
8
8
|
pycupra/utilities.py,sha256=6sDxWP13-XtxmqhuBJBGdVbkj48BQ9AxFMrBPxH0J7g,2679
|
9
|
-
pycupra/vehicle.py,sha256=
|
9
|
+
pycupra/vehicle.py,sha256=12pFVqgIRkPMJ9IoBt0TAuSS4RRQOdTCq4-ltNtbN9c,162376
|
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.
|
22
|
-
pycupra-0.1.
|
23
|
-
pycupra-0.1.
|
24
|
-
pycupra-0.1.
|
25
|
-
pycupra-0.1.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|