pycupra 0.0.6__py3-none-any.whl → 0.0.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 +9 -1
- pycupra/dashboard.py +35 -3
- pycupra/vehicle.py +57 -14
- {pycupra-0.0.6.dist-info → pycupra-0.0.7.dist-info}/METADATA +1 -1
- pycupra-0.0.7.dist-info/RECORD +13 -0
- pycupra-0.0.6.dist-info/RECORD +0 -13
- {pycupra-0.0.6.dist-info → pycupra-0.0.7.dist-info}/WHEEL +0 -0
- {pycupra-0.0.6.dist-info → pycupra-0.0.7.dist-info}/licenses/LICENSE +0 -0
- {pycupra-0.0.6.dist-info → pycupra-0.0.7.dist-info}/top_level.txt +0 -0
pycupra/__version__.py
CHANGED
pycupra/connection.py
CHANGED
@@ -694,7 +694,7 @@ class Connection:
|
|
694
694
|
for vehicle in self.vehicles:
|
695
695
|
if vehicle.vin not in update_list:
|
696
696
|
_LOGGER.debug(f'Adding {vehicle.vin} for data refresh')
|
697
|
-
update_list.append(vehicle.update())
|
697
|
+
update_list.append(vehicle.update(updateType=1))
|
698
698
|
else:
|
699
699
|
_LOGGER.debug(f'VIN {vehicle.vin} is already queued for data refresh')
|
700
700
|
|
@@ -884,6 +884,14 @@ class Connection:
|
|
884
884
|
_LOGGER.info('Unhandled error while trying to fetch mycar data')
|
885
885
|
except Exception as error:
|
886
886
|
_LOGGER.warning(f'Could not fetch mycar report, error: {error}')
|
887
|
+
if data=={}:
|
888
|
+
return False
|
889
|
+
return data
|
890
|
+
|
891
|
+
async def getMileage(self, vin, baseurl):
|
892
|
+
"""Get car information from customer profile, VIN, nickname, etc."""
|
893
|
+
await self.set_token(self._session_auth_brand)
|
894
|
+
data={}
|
887
895
|
try:
|
888
896
|
response = await self.get(eval(f"f'{API_MILEAGE}'"))
|
889
897
|
if response.get('mileageKm', {}):
|
pycupra/dashboard.py
CHANGED
@@ -444,9 +444,9 @@ class RequestFlash(Switch):
|
|
444
444
|
return dict(last_result = self.vehicle.honkandflash_action_status)
|
445
445
|
|
446
446
|
|
447
|
-
class
|
447
|
+
class RequestRefresh(Switch):
|
448
448
|
def __init__(self):
|
449
|
-
super().__init__(attr="refresh_data", name="
|
449
|
+
super().__init__(attr="refresh_data", name="Request wakeup vehicle", icon="mdi:car-connected")
|
450
450
|
|
451
451
|
@property
|
452
452
|
def state(self):
|
@@ -454,7 +454,7 @@ class RequestUpdate(Switch):
|
|
454
454
|
|
455
455
|
async def turn_on(self):
|
456
456
|
await self.vehicle.set_refresh()
|
457
|
-
await self.vehicle.update()
|
457
|
+
await self.vehicle.update(updateType=1) #full update after set_refresh
|
458
458
|
if self.callback is not None:
|
459
459
|
self.callback()
|
460
460
|
|
@@ -470,6 +470,31 @@ class RequestUpdate(Switch):
|
|
470
470
|
return dict(last_result = self.vehicle.refresh_action_status)
|
471
471
|
|
472
472
|
|
473
|
+
class RequestUpdate(Switch):
|
474
|
+
def __init__(self):
|
475
|
+
super().__init__(attr="update_data", name="Request full update", icon="mdi:timer-refresh")
|
476
|
+
|
477
|
+
@property
|
478
|
+
def state(self):
|
479
|
+
return False #self.vehicle.update
|
480
|
+
|
481
|
+
async def turn_on(self):
|
482
|
+
await self.vehicle.update(updateType=1) #full update after set_refresh
|
483
|
+
if self.callback is not None:
|
484
|
+
self.callback()
|
485
|
+
|
486
|
+
async def turn_off(self):
|
487
|
+
pass
|
488
|
+
|
489
|
+
@property
|
490
|
+
def assumed_state(self):
|
491
|
+
return False
|
492
|
+
|
493
|
+
#@property
|
494
|
+
#def attributes(self):
|
495
|
+
# return dict()
|
496
|
+
|
497
|
+
|
473
498
|
class ElectricClimatisation(Switch):
|
474
499
|
def __init__(self):
|
475
500
|
super().__init__(attr="electric_climatisation", name="Electric Climatisation", icon="mdi:radiator")
|
@@ -916,6 +941,7 @@ def create_instruments():
|
|
916
941
|
TrunkLock(),
|
917
942
|
RequestFlash(),
|
918
943
|
RequestHonkAndFlash(),
|
944
|
+
RequestRefresh(),
|
919
945
|
RequestUpdate(),
|
920
946
|
WindowHeater(),
|
921
947
|
BatteryClimatisation(),
|
@@ -1000,6 +1026,12 @@ def create_instruments():
|
|
1000
1026
|
icon="mdi:clock",
|
1001
1027
|
device_class="timestamp"
|
1002
1028
|
),
|
1029
|
+
Sensor(
|
1030
|
+
attr="last_full_update",
|
1031
|
+
name="Last full update",
|
1032
|
+
icon="mdi:clock",
|
1033
|
+
device_class="timestamp"
|
1034
|
+
),
|
1003
1035
|
Sensor(
|
1004
1036
|
attr="parking_time",
|
1005
1037
|
name="Parking time",
|
pycupra/vehicle.py
CHANGED
@@ -78,10 +78,10 @@ class Vehicle:
|
|
78
78
|
# Init and update vehicle data
|
79
79
|
async def discover(self):
|
80
80
|
"""Discover vehicle and initial data."""
|
81
|
-
await asyncio.gather(
|
82
|
-
|
83
|
-
|
84
|
-
)
|
81
|
+
#await asyncio.gather(
|
82
|
+
# self.get_basiccardata(),
|
83
|
+
# return_exceptions=True
|
84
|
+
#)
|
85
85
|
# Extract information of relevant capabilities
|
86
86
|
for capa in self._capabilities:
|
87
87
|
id=capa.get('id', '')
|
@@ -104,13 +104,13 @@ class Vehicle:
|
|
104
104
|
self._relevantCapabilties[id].update(data)
|
105
105
|
|
106
106
|
|
107
|
-
await self.get_trip_statistic()
|
107
|
+
await self.get_trip_statistic()
|
108
108
|
# Get URLs for model image
|
109
|
-
self._modelimages = await self.get_modelimageurl()
|
109
|
+
self._modelimages = await self.get_modelimageurl()
|
110
110
|
|
111
111
|
self._discovered = datetime.now()
|
112
112
|
|
113
|
-
async def update(self):
|
113
|
+
async def update(self, updateType=0):
|
114
114
|
"""Try to fetch data for all known API endpoints."""
|
115
115
|
# Update vehicle information if not discovered or stale information
|
116
116
|
if not self._discovered:
|
@@ -125,6 +125,21 @@ class Vehicle:
|
|
125
125
|
# Fetch all data if car is not deactivated
|
126
126
|
if not self.deactivated:
|
127
127
|
try:
|
128
|
+
# Data to be updated most often
|
129
|
+
await asyncio.gather(
|
130
|
+
self.get_charger(),
|
131
|
+
self.get_basiccardata(),
|
132
|
+
return_exceptions=True
|
133
|
+
)
|
134
|
+
|
135
|
+
fullUpdateExpired = datetime.now(timezone.utc) - timedelta(seconds= 1100)
|
136
|
+
if hasattr(self, '_last_full_update'):
|
137
|
+
_LOGGER.debug(f'last_full_update= {self._last_full_update}, fullUpdateExpired= {fullUpdateExpired}.')
|
138
|
+
if updateType!=1 and (hasattr(self, '_last_full_update') and self._last_full_update>fullUpdateExpired):
|
139
|
+
_LOGGER.debug(f'Just performed small update for vehicle with VIN {self.vin}.')
|
140
|
+
return True
|
141
|
+
|
142
|
+
# Data to be updated less often
|
128
143
|
await asyncio.gather(
|
129
144
|
self.get_preheater(),
|
130
145
|
self.get_climater(),
|
@@ -132,13 +147,14 @@ class Vehicle:
|
|
132
147
|
self.get_position(),
|
133
148
|
self.get_statusreport(),
|
134
149
|
self.get_vehicleHealthWarnings(),
|
135
|
-
self.get_charger(),
|
136
150
|
self.get_departure_timers(),
|
137
151
|
self.get_departure_profiles(),
|
138
|
-
self.
|
152
|
+
self.get_mileage(),
|
139
153
|
#self.get_modelimageurl(), #commented out, because getting the images discover() should be sufficient
|
140
154
|
return_exceptions=True
|
141
155
|
)
|
156
|
+
self._last_full_update = datetime.now(timezone.utc)
|
157
|
+
_LOGGER.debug(f'Performed full update for vehicle with VIN {self.vin}.')
|
142
158
|
except:
|
143
159
|
raise SeatException("Update failed")
|
144
160
|
return True
|
@@ -158,6 +174,12 @@ class Vehicle:
|
|
158
174
|
if data:
|
159
175
|
self._states.update(data)
|
160
176
|
|
177
|
+
async def get_mileage(self):
|
178
|
+
"""Fetch basic car data."""
|
179
|
+
data = await self._connection.getMileage(self.vin, self._apibase)
|
180
|
+
if data:
|
181
|
+
self._states.update(data)
|
182
|
+
|
161
183
|
async def get_preheater(self):
|
162
184
|
"""Fetch pre-heater data if function is enabled."""
|
163
185
|
_LOGGER.info('get_preheater() not implemented yet')
|
@@ -320,7 +342,7 @@ class Vehicle:
|
|
320
342
|
raise SeatInvalidRequestException('Remote start/stop of charger is not supported.')
|
321
343
|
if self._requests['batterycharge'].get('id', False):
|
322
344
|
timestamp = self._requests.get('batterycharge', {}).get('timestamp', datetime.now())
|
323
|
-
expired = datetime.now() - timedelta(minutes=
|
345
|
+
expired = datetime.now() - timedelta(minutes=1)
|
324
346
|
if expired > timestamp:
|
325
347
|
self._requests.get('batterycharge', {}).pop('id')
|
326
348
|
else:
|
@@ -574,7 +596,7 @@ class Vehicle:
|
|
574
596
|
raise SeatInvalidRequestException('Departure timers are not supported.')
|
575
597
|
if self._requests['departuretimer'].get('id', False):
|
576
598
|
timestamp = self._requests.get('departuretimer', {}).get('timestamp', datetime.now())
|
577
|
-
expired = datetime.now() - timedelta(minutes=
|
599
|
+
expired = datetime.now() - timedelta(minutes=1)
|
578
600
|
if expired > timestamp:
|
579
601
|
self._requests.get('departuretimer', {}).pop('id')
|
580
602
|
else:
|
@@ -848,7 +870,7 @@ class Vehicle:
|
|
848
870
|
raise SeatInvalidRequestException('Remote control of climatisation functions is not supported.')
|
849
871
|
if self._requests['climatisation'].get('id', False):
|
850
872
|
timestamp = self._requests.get('climatisation', {}).get('timestamp', datetime.now())
|
851
|
-
expired = datetime.now() - timedelta(minutes=
|
873
|
+
expired = datetime.now() - timedelta(minutes=1)
|
852
874
|
if expired > timestamp:
|
853
875
|
self._requests.get('climatisation', {}).pop('id')
|
854
876
|
else:
|
@@ -913,7 +935,7 @@ class Vehicle:
|
|
913
935
|
raise SeatInvalidRequestException('No parking heater support.')
|
914
936
|
if self._requests['preheater'].get('id', False):
|
915
937
|
timestamp = self._requests.get('preheater', {}).get('timestamp', datetime.now())
|
916
|
-
expired = datetime.now() - timedelta(minutes=
|
938
|
+
expired = datetime.now() - timedelta(minutes=1)
|
917
939
|
if expired > timestamp:
|
918
940
|
self._requests.get('preheater', {}).pop('id')
|
919
941
|
else:
|
@@ -1053,7 +1075,7 @@ class Vehicle:
|
|
1053
1075
|
raise SeatInvalidRequestException('Data refresh is not supported.')
|
1054
1076
|
if self._requests['refresh'].get('id', False):
|
1055
1077
|
timestamp = self._requests.get('refresh', {}).get('timestamp', datetime.now() - timedelta(minutes=5))
|
1056
|
-
expired = datetime.now() - timedelta(minutes=
|
1078
|
+
expired = datetime.now() - timedelta(minutes=1)
|
1057
1079
|
if expired > timestamp:
|
1058
1080
|
self._requests.get('refresh', {}).pop('id')
|
1059
1081
|
else:
|
@@ -1228,6 +1250,17 @@ class Vehicle:
|
|
1228
1250
|
if 'updatedAt' in self.attrs.get('status', {}):
|
1229
1251
|
return True
|
1230
1252
|
|
1253
|
+
# Update status
|
1254
|
+
@property
|
1255
|
+
def last_full_update(self):
|
1256
|
+
"""Return when the last full update for the vehicle took place."""
|
1257
|
+
return self._last_full_update.astimezone(tz=None)
|
1258
|
+
|
1259
|
+
@property
|
1260
|
+
def is_last_full_update_supported(self):
|
1261
|
+
"""Return when last full update for vehicle took place."""
|
1262
|
+
return True
|
1263
|
+
|
1231
1264
|
# Service information
|
1232
1265
|
@property
|
1233
1266
|
def distance(self):
|
@@ -2683,6 +2716,16 @@ class Vehicle:
|
|
2683
2716
|
if self._connectivities.get('mode', '') == 'online':
|
2684
2717
|
return True
|
2685
2718
|
|
2719
|
+
@property
|
2720
|
+
def update_data(self):
|
2721
|
+
"""Get state of data update"""
|
2722
|
+
return False
|
2723
|
+
|
2724
|
+
@property
|
2725
|
+
def is_update_data_supported(self):
|
2726
|
+
"""Data update is supported."""
|
2727
|
+
return True
|
2728
|
+
|
2686
2729
|
# Honk and flash
|
2687
2730
|
@property
|
2688
2731
|
def request_honkandflash(self):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pycupra
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.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
|
@@ -0,0 +1,13 @@
|
|
1
|
+
pycupra/__init__.py,sha256=VPzUfKd5mBFD1UERNV61FbGHih5dQPupLgIfYtmIUi4,230
|
2
|
+
pycupra/__version__.py,sha256=sE47EQF8GjjvZy9jhhygnhK2JLO76vFrSBB6HfkoIW4,207
|
3
|
+
pycupra/connection.py,sha256=LK1v3Eb37lbVKIbQWIjn4xAIAFJqxXwlguX5iq2Ylm8,81393
|
4
|
+
pycupra/const.py,sha256=VEYH8TUsJGJwBwloaajwoElYd0qxE7oesvoagvDdE-4,10161
|
5
|
+
pycupra/dashboard.py,sha256=Dqs4qDF-rEoYXoS7NrNsvRMsCGzoAjVUEbfTSOdDAXo,41310
|
6
|
+
pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
|
7
|
+
pycupra/utilities.py,sha256=cH4MiIzT2WlHgmnl_E7rR0R5LvCXfDNvirJolct50V8,2563
|
8
|
+
pycupra/vehicle.py,sha256=cEg7wG4WX6p4MfShRGZZ955cqvYERI6CmfWSN5NanSQ,122147
|
9
|
+
pycupra-0.0.7.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
10
|
+
pycupra-0.0.7.dist-info/METADATA,sha256=0W-3PCD7jSDrUtYauZKSzFfSe_dzbTqREQjNxlv28Qo,2578
|
11
|
+
pycupra-0.0.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
12
|
+
pycupra-0.0.7.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
|
13
|
+
pycupra-0.0.7.dist-info/RECORD,,
|
pycupra-0.0.6.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
pycupra/__init__.py,sha256=VPzUfKd5mBFD1UERNV61FbGHih5dQPupLgIfYtmIUi4,230
|
2
|
-
pycupra/__version__.py,sha256=YbGN0knQ3fpcD8GGO6OA7ZBYa-fQ4unLaw-NTYREVn8,207
|
3
|
-
pycupra/connection.py,sha256=4bcaHn6AwAAY9e3MfVwlPMQzKJZQo_BZttts0lubnro,81120
|
4
|
-
pycupra/const.py,sha256=VEYH8TUsJGJwBwloaajwoElYd0qxE7oesvoagvDdE-4,10161
|
5
|
-
pycupra/dashboard.py,sha256=difLM3R2uXUrVslUjqzH8nN6WPJA-u26rHlGUU6W8Oo,40454
|
6
|
-
pycupra/exceptions.py,sha256=Nq_F79GP8wjHf5lpvPy9TbSIrRHAJrFMo0T1N9TcgSQ,2917
|
7
|
-
pycupra/utilities.py,sha256=cH4MiIzT2WlHgmnl_E7rR0R5LvCXfDNvirJolct50V8,2563
|
8
|
-
pycupra/vehicle.py,sha256=vlSuvrspX_I1RlS8KoZkN09u5cCNNdcIslsA0xPUuqA,120442
|
9
|
-
pycupra-0.0.6.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
10
|
-
pycupra-0.0.6.dist-info/METADATA,sha256=k-diSYUQOySb2FxopmNeWMOXqf_FQG1A5yGwnMpo03M,2578
|
11
|
-
pycupra-0.0.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
12
|
-
pycupra-0.0.6.dist-info/top_level.txt,sha256=9Lbj_jG4JvpGwt6K3AwhWFc0XieDnuHFOP4x44wSXSQ,8
|
13
|
-
pycupra-0.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|