carconnectivity-connector-skoda 0.1a3__py3-none-any.whl → 0.1a4__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.
Potentially problematic release.
This version of carconnectivity-connector-skoda might be problematic. Click here for more details.
- {carconnectivity_connector_skoda-0.1a3.dist-info → carconnectivity_connector_skoda-0.1a4.dist-info}/METADATA +1 -1
- {carconnectivity_connector_skoda-0.1a3.dist-info → carconnectivity_connector_skoda-0.1a4.dist-info}/RECORD +8 -8
- carconnectivity_connectors/skoda/_version.py +1 -1
- carconnectivity_connectors/skoda/connector.py +10 -13
- carconnectivity_connectors/skoda/mqtt_client.py +27 -10
- {carconnectivity_connector_skoda-0.1a3.dist-info → carconnectivity_connector_skoda-0.1a4.dist-info}/LICENSE +0 -0
- {carconnectivity_connector_skoda-0.1a3.dist-info → carconnectivity_connector_skoda-0.1a4.dist-info}/WHEEL +0 -0
- {carconnectivity_connector_skoda-0.1a3.dist-info → carconnectivity_connector_skoda-0.1a4.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
carconnectivity_connectors/skoda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
carconnectivity_connectors/skoda/_version.py,sha256=
|
|
2
|
+
carconnectivity_connectors/skoda/_version.py,sha256=k2_F9qhiZ-QdrUSPYbgP7u-QuYMDZVq_7Ev7i0J23L0,408
|
|
3
3
|
carconnectivity_connectors/skoda/capability.py,sha256=JlNEaisVYF8qWv0wNDHTaas36uIpTIQ3NVR69wesiYQ,4513
|
|
4
|
-
carconnectivity_connectors/skoda/connector.py,sha256=
|
|
5
|
-
carconnectivity_connectors/skoda/mqtt_client.py,sha256=
|
|
4
|
+
carconnectivity_connectors/skoda/connector.py,sha256=uAf1WcSQ68fkMF_R2zPjLP5vJYjk1QzGcg-ZdX4mPZo,42473
|
|
5
|
+
carconnectivity_connectors/skoda/mqtt_client.py,sha256=7Hn-TqBl7VsN7e7DoPLvXZQ2UsSaOl1P0bMhbQQPX7k,18933
|
|
6
6
|
carconnectivity_connectors/skoda/vehicle.py,sha256=H3GRDNimMghFwFi--y9BsgoSK3pMibNf_l6SsDN6gvQ,2759
|
|
7
7
|
carconnectivity_connectors/skoda/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
carconnectivity_connectors/skoda/auth/auth_util.py,sha256=dGLUbUre0HBsTg_Ii5vW34f8DLrCykYJYCyzEvUBBEE,4434
|
|
@@ -11,8 +11,8 @@ carconnectivity_connectors/skoda/auth/openid_session.py,sha256=PLWSSKw9Dg7hBbhzJ
|
|
|
11
11
|
carconnectivity_connectors/skoda/auth/session_manager.py,sha256=Uf1vujuDBYUCAXhYToOsZkgbTtfmY3Qe0ICTfwomBpI,2899
|
|
12
12
|
carconnectivity_connectors/skoda/auth/skoda_web_session.py,sha256=cjzMkzx473Sh-4RgZAQULeRRcxB1MboddldCVM_y5LE,10640
|
|
13
13
|
carconnectivity_connectors/skoda/auth/helpers/blacklist_retry.py,sha256=f3wsiY5bpHDBxp7Va1Mv9nKJ4u3qnCHZZmDu78_AhMk,1251
|
|
14
|
-
carconnectivity_connector_skoda-0.
|
|
15
|
-
carconnectivity_connector_skoda-0.
|
|
16
|
-
carconnectivity_connector_skoda-0.
|
|
17
|
-
carconnectivity_connector_skoda-0.
|
|
18
|
-
carconnectivity_connector_skoda-0.
|
|
14
|
+
carconnectivity_connector_skoda-0.1a4.dist-info/LICENSE,sha256=PIwI1alwDyOfvEQHdGCm2u9uf_mGE8030xZDfun0xTo,1071
|
|
15
|
+
carconnectivity_connector_skoda-0.1a4.dist-info/METADATA,sha256=uAZPqSaCZIMMbLZLSkOBAA0XJyinzwcDNzrjmtKZy18,5326
|
|
16
|
+
carconnectivity_connector_skoda-0.1a4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
17
|
+
carconnectivity_connector_skoda-0.1a4.dist-info/top_level.txt,sha256=KqA8GviZsDH4PtmnwSQsz0HB_w-TWkeEHLIRNo5dTaI,27
|
|
18
|
+
carconnectivity_connector_skoda-0.1a4.dist-info/RECORD,,
|
|
@@ -123,8 +123,8 @@ class Connector(BaseConnector):
|
|
|
123
123
|
session: requests.Session = self._manager.get_session(Service.MY_SKODA, SessionUser(username=username, password=password))
|
|
124
124
|
if not isinstance(session, MySkodaSession):
|
|
125
125
|
raise AuthenticationError('Could not create session')
|
|
126
|
-
self.
|
|
127
|
-
self.
|
|
126
|
+
self.session: MySkodaSession = session
|
|
127
|
+
self.session.refresh()
|
|
128
128
|
|
|
129
129
|
self._elapsed: List[timedelta] = []
|
|
130
130
|
|
|
@@ -142,11 +142,8 @@ class Connector(BaseConnector):
|
|
|
142
142
|
def _background_connect_loop(self) -> None:
|
|
143
143
|
while not self._stop_event.is_set():
|
|
144
144
|
try:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
LOG.info('Connecting to Skoda MQTT-Server')
|
|
148
|
-
self._mqtt_client.connect_client(access_token)
|
|
149
|
-
break
|
|
145
|
+
self._mqtt_client.connect()
|
|
146
|
+
break
|
|
150
147
|
except ConnectionRefusedError as e:
|
|
151
148
|
LOG.error('Could not connect to MQTT-Server: %s, will retry in 10 seconds', e)
|
|
152
149
|
self._stop_event.wait(10)
|
|
@@ -214,7 +211,7 @@ class Connector(BaseConnector):
|
|
|
214
211
|
if self._background_connect_thread is not None:
|
|
215
212
|
self._background_connect_thread.join()
|
|
216
213
|
self.persist()
|
|
217
|
-
self.
|
|
214
|
+
self.session.close()
|
|
218
215
|
return super().shutdown()
|
|
219
216
|
|
|
220
217
|
def fetch_all(self) -> None:
|
|
@@ -236,7 +233,7 @@ class Connector(BaseConnector):
|
|
|
236
233
|
None
|
|
237
234
|
"""
|
|
238
235
|
url = 'https://mysmob.api.connect.skoda-auto.cz/api/v1/users'
|
|
239
|
-
data: Dict[str, Any] | None = self._fetch_data(url, session=self.
|
|
236
|
+
data: Dict[str, Any] | None = self._fetch_data(url, session=self.session)
|
|
240
237
|
if data:
|
|
241
238
|
if 'id' in data and data['id'] is not None:
|
|
242
239
|
self.user_id = data['id']
|
|
@@ -252,7 +249,7 @@ class Connector(BaseConnector):
|
|
|
252
249
|
"""
|
|
253
250
|
garage: Garage = self.car_connectivity.garage
|
|
254
251
|
url = 'https://mysmob.api.connect.skoda-auto.cz/api/v2/garage'
|
|
255
|
-
data: Dict[str, Any] | None = self._fetch_data(url, session=self.
|
|
252
|
+
data: Dict[str, Any] | None = self._fetch_data(url, session=self.session)
|
|
256
253
|
seen_vehicle_vins: set[str] = set()
|
|
257
254
|
if data is not None:
|
|
258
255
|
if 'vehicles' in data and data['vehicles'] is not None:
|
|
@@ -293,7 +290,7 @@ class Connector(BaseConnector):
|
|
|
293
290
|
raise APIError('VIN is missing')
|
|
294
291
|
url = f'https://mysmob.api.connect.skoda-auto.cz/api/v2/garage/vehicles/{vin}?' \
|
|
295
292
|
'connectivityGenerations=MOD1&connectivityGenerations=MOD2&connectivityGenerations=MOD3&connectivityGenerations=MOD4'
|
|
296
|
-
vehicle_data: Dict[str, Any] | None = self._fetch_data(url, self.
|
|
293
|
+
vehicle_data: Dict[str, Any] | None = self._fetch_data(url, self.session)
|
|
297
294
|
if vehicle_data:
|
|
298
295
|
if 'softwareVersion' in vehicle_data and vehicle_data['softwareVersion'] is not None:
|
|
299
296
|
vehicle.software.version._set_value(vehicle_data['softwareVersion']) # pylint: disable=protected-access
|
|
@@ -331,7 +328,7 @@ class Connector(BaseConnector):
|
|
|
331
328
|
log_extra_keys(LOG_API, 'api/v2/garage/vehicles/VIN', vehicle_data, {'softwareVersion'})
|
|
332
329
|
|
|
333
330
|
url = f'https://mysmob.api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}/driving-range'
|
|
334
|
-
range_data: Dict[str, Any] | None = self._fetch_data(url, self.
|
|
331
|
+
range_data: Dict[str, Any] | None = self._fetch_data(url, self.session)
|
|
335
332
|
if range_data:
|
|
336
333
|
captured_at: datetime = robust_time_parse(range_data['carCapturedTimestamp'])
|
|
337
334
|
# Check vehicle type and if it does not match the current vehicle type, create a new vehicle object using copy constructor
|
|
@@ -418,7 +415,7 @@ class Connector(BaseConnector):
|
|
|
418
415
|
'secondaryEngineRange'})
|
|
419
416
|
|
|
420
417
|
url = f'https://api.connect.skoda-auto.cz/api/v2/vehicle-status/{vin}'
|
|
421
|
-
vehicle_status_data: Dict[str, Any] | None = self._fetch_data(url, self.
|
|
418
|
+
vehicle_status_data: Dict[str, Any] | None = self._fetch_data(url, self.session)
|
|
422
419
|
if vehicle_status_data:
|
|
423
420
|
if 'remote' in vehicle_status_data and vehicle_status_data['remote'] is not None:
|
|
424
421
|
vehicle_status_data = vehicle_status_data['remote']
|
|
@@ -37,28 +37,45 @@ class SkodaMQTTClient(Client): # pylint: disable=too-many-instance-attributes
|
|
|
37
37
|
|
|
38
38
|
self.username = 'android-app'
|
|
39
39
|
|
|
40
|
+
self.on_pre_connect = self._on_pre_connect_callback
|
|
40
41
|
self.on_connect = self._on_connect_callback
|
|
41
42
|
self.on_message = self._on_message_callback
|
|
42
43
|
self.on_disconnect = self._on_disconnect_callback
|
|
43
44
|
self.on_subscribe = self._on_subscribe_callback
|
|
44
45
|
self.subscribed_topics: Set[str] = set()
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
self.tls_set(cert_reqs=ssl.CERT_NONE)
|
|
48
|
+
|
|
49
|
+
def connect(self, *args, **kwargs) -> MQTTErrorCode:
|
|
47
50
|
"""
|
|
48
|
-
Connects the MQTT client
|
|
51
|
+
Connects the MQTT client to the skoda server.
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
Returns:
|
|
54
|
+
MQTTErrorCode: The result of the connection attempt.
|
|
55
|
+
"""
|
|
56
|
+
return super().connect(*args, host='mqtt.messagehub.de', port=8883, keepalive=60, **kwargs)
|
|
57
|
+
|
|
58
|
+
def _on_pre_connect_callback(self, client, userdata) -> None:
|
|
59
|
+
"""
|
|
60
|
+
Callback function that is called before the MQTT client connects to the broker.
|
|
61
|
+
|
|
62
|
+
Sets the client's password to the access token.
|
|
52
63
|
|
|
53
64
|
Args:
|
|
54
|
-
|
|
65
|
+
client: The MQTT client instance (unused).
|
|
66
|
+
userdata: The user data passed to the callback (unused).
|
|
55
67
|
|
|
56
68
|
Returns:
|
|
57
|
-
|
|
69
|
+
None
|
|
58
70
|
"""
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
del client
|
|
72
|
+
del userdata
|
|
73
|
+
|
|
74
|
+
if self._skoda_connector.session.expired or self._skoda_connector.session.access_token is None:
|
|
75
|
+
self._skoda_connector.session.refresh()
|
|
76
|
+
if not self._skoda_connector.session.expired and self._skoda_connector.session.access_token is not None:
|
|
77
|
+
# pylint: disable-next=attribute-defined-outside-init # this is a false positive, password has a setter in super class
|
|
78
|
+
self._password = self._skoda_connector.session.access_token # This is a bit hacky but if password attribute is used here there is an Exception
|
|
62
79
|
|
|
63
80
|
def _on_carconnectivity_vehicle_enabled(self, element, flags):
|
|
64
81
|
"""
|
|
@@ -268,7 +285,7 @@ class SkodaMQTTClient(Client): # pylint: disable=too-many-instance-attributes
|
|
|
268
285
|
del properties
|
|
269
286
|
# reason_code 0 means success
|
|
270
287
|
if reason_code == 0:
|
|
271
|
-
LOG.info('Connected to MQTT
|
|
288
|
+
LOG.info('Connected to Skoda MQTT server')
|
|
272
289
|
self._skoda_connector.connected._set_value(value=True) # pylint: disable=protected-access
|
|
273
290
|
observer_flags: Observable.ObserverEvent = Observable.ObserverEvent.ENABLED | Observable.ObserverEvent.DISABLED
|
|
274
291
|
self._skoda_connector.car_connectivity.garage.add_observer(observer=self._on_carconnectivity_vehicle_enabled,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|