hyundai-kia-connect-api 3.17.0__tar.gz → 3.17.2__tar.gz

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.
Files changed (45) hide show
  1. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/PKG-INFO +1 -1
  2. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/KiaUvoAPIUSA.py +21 -5
  3. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/KiaUvoApiAU.py +13 -8
  4. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/PKG-INFO +1 -1
  5. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/setup.py +1 -1
  6. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/AUTHORS.rst +0 -0
  7. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/CONTRIBUTING.rst +0 -0
  8. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/HISTORY.rst +0 -0
  9. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/LICENSE +0 -0
  10. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/MANIFEST.in +0 -0
  11. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/README.rst +0 -0
  12. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/Makefile +0 -0
  13. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/authors.rst +0 -0
  14. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/conf.py +0 -0
  15. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/contributing.rst +0 -0
  16. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/history.rst +0 -0
  17. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/index.rst +0 -0
  18. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/installation.rst +0 -0
  19. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/make.bat +0 -0
  20. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/readme.rst +0 -0
  21. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/docs/usage.rst +0 -0
  22. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/ApiImpl.py +0 -0
  23. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py +0 -0
  24. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/KiaUvoApiCA.py +0 -0
  25. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/KiaUvoApiCN.py +0 -0
  26. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/KiaUvoApiEU.py +0 -0
  27. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/Token.py +0 -0
  28. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/Vehicle.py +0 -0
  29. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/VehicleManager.py +0 -0
  30. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/__init__.py +0 -0
  31. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/const.py +0 -0
  32. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/exceptions.py +0 -0
  33. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api/utils.py +0 -0
  34. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/SOURCES.txt +0 -0
  35. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/dependency_links.txt +0 -0
  36. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/not-zip-safe +0 -0
  37. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/requires.txt +0 -0
  38. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/hyundai_kia_connect_api.egg-info/top_level.txt +0 -0
  39. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/requirements.txt +0 -0
  40. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/setup.cfg +0 -0
  41. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/tests/__init__.py +0 -0
  42. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/tests/au_login_test.py +0 -0
  43. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/tests/ca_login_test.py +0 -0
  44. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/tests/eu_check_response_for_errors_test.py +0 -0
  45. {hyundai_kia_connect_api-3.17.0 → hyundai_kia_connect_api-3.17.2}/tests/eu_login_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.17.0
3
+ Version: 3.17.2
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/fuatakgun/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -6,6 +6,7 @@ import logging
6
6
  import random
7
7
  import re
8
8
  import secrets
9
+ import ssl
9
10
  import string
10
11
  import time
11
12
  import typing
@@ -14,6 +15,8 @@ from datetime import datetime
14
15
  import pytz
15
16
  import requests
16
17
  from requests import RequestException, Response
18
+ from requests.adapters import HTTPAdapter
19
+ from urllib3.util.ssl_ import create_urllib3_context
17
20
 
18
21
  from .ApiImpl import ApiImpl, ClimateRequestOptions
19
22
  from .Token import Token
@@ -31,6 +34,17 @@ from .utils import get_child_value
31
34
  _LOGGER = logging.getLogger(__name__)
32
35
 
33
36
 
37
+ # This is the key part of our patch. We get the standard SSLContext that requests would
38
+ # normally use, and add ciphers that Kia USA may need for compatibility.
39
+ class KiaSSLAdapter(HTTPAdapter):
40
+ def init_poolmanager(self, *args, **kwargs):
41
+ context = create_urllib3_context(
42
+ ciphers="DEFAULT:@SECLEVEL=1", ssl_version=ssl.PROTOCOL_TLSv1_2
43
+ )
44
+ kwargs["ssl_context"] = context
45
+ return super().init_poolmanager(*args, **kwargs)
46
+
47
+
34
48
  class AuthError(RequestException):
35
49
  """AuthError"""
36
50
 
@@ -108,6 +122,8 @@ class KiaUvoAPIUSA(ApiImpl):
108
122
 
109
123
  self.BASE_URL: str = "api.owners.kia.com"
110
124
  self.API_URL: str = "https://" + self.BASE_URL + "/apigw/v1/"
125
+ self.session = requests.Session()
126
+ self.session.mount("https://", KiaSSLAdapter())
111
127
 
112
128
  def api_headers(self) -> dict:
113
129
  offset = time.localtime().tm_gmtoff / 60 / 60
@@ -149,7 +165,7 @@ class KiaUvoAPIUSA(ApiImpl):
149
165
  self, token: Token, url: str, json_body: dict, vehicle: Vehicle
150
166
  ) -> Response:
151
167
  headers = self.authed_api_headers(token, vehicle)
152
- return requests.post(url, json=json_body, headers=headers)
168
+ return self.session.post(url, json=json_body, headers=headers)
153
169
 
154
170
  @request_with_active_session
155
171
  @request_with_logging
@@ -157,7 +173,7 @@ class KiaUvoAPIUSA(ApiImpl):
157
173
  self, token: Token, url: str, vehicle: Vehicle
158
174
  ) -> Response:
159
175
  headers = self.authed_api_headers(token, vehicle)
160
- return requests.get(url, headers=headers)
176
+ return self.session.get(url, headers=headers)
161
177
 
162
178
  def login(self, username: str, password: str) -> Token:
163
179
  """Login into cloud endpoints and return Token"""
@@ -170,7 +186,7 @@ class KiaUvoAPIUSA(ApiImpl):
170
186
  "userCredential": {"userId": username, "password": password},
171
187
  }
172
188
  headers = self.api_headers()
173
- response = requests.post(url, json=data, headers=headers)
189
+ response = self.session.post(url, json=data, headers=headers)
174
190
  _LOGGER.debug(f"{DOMAIN} - Sign In Response {response.text}")
175
191
  session_id = response.headers.get("sid")
176
192
  if not session_id:
@@ -191,7 +207,7 @@ class KiaUvoAPIUSA(ApiImpl):
191
207
  url = self.API_URL + "ownr/gvl"
192
208
  headers = self.api_headers()
193
209
  headers["sid"] = token.access_token
194
- response = requests.get(url, headers=headers)
210
+ response = self.session.get(url, headers=headers)
195
211
  _LOGGER.debug(f"{DOMAIN} - Get Vehicles Response {response.text}")
196
212
  response = response.json()
197
213
  result = []
@@ -216,7 +232,7 @@ class KiaUvoAPIUSA(ApiImpl):
216
232
  url = self.API_URL + "ownr/gvl"
217
233
  headers = self.api_headers()
218
234
  headers["sid"] = token.access_token
219
- response = requests.get(url, headers=headers)
235
+ response = self.session.get(url, headers=headers)
220
236
  _LOGGER.debug(f"{DOMAIN} - Get Vehicles Response {response.text}")
221
237
  _LOGGER.debug(f"{DOMAIN} - Vehicles Type Passed in: {type(vehicles)}")
222
238
  _LOGGER.debug(f"{DOMAIN} - Vehicles Passed in: {vehicles}")
@@ -53,7 +53,9 @@ from .utils import (
53
53
  _LOGGER = logging.getLogger(__name__)
54
54
 
55
55
  USER_AGENT_OK_HTTP: str = "okhttp/3.12.0"
56
- USER_AGENT_MOZILLA: str = "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" # noqa
56
+ USER_AGENT_MOZILLA: str = (
57
+ "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" # noqa
58
+ )
57
59
 
58
60
 
59
61
  def _check_response_for_errors(response: dict) -> None:
@@ -104,12 +106,16 @@ class KiaUvoApiAU(ApiImpl):
104
106
  self.BASE_URL: str = "au-apigw.ccs.kia.com.au:8082"
105
107
  self.CCSP_SERVICE_ID: str = "8acb778a-b918-4a8d-8624-73a0beb64289"
106
108
  self.APP_ID: str = "4ad4dcde-be23-48a8-bc1c-91b94f5c06f8" # Android app ID
107
- self.BASIC_AUTHORIZATION: str = "Basic OGFjYjc3OGEtYjkxOC00YThkLTg2MjQtNzNhMGJlYjY0Mjg5OjdTY01NbTZmRVlYZGlFUEN4YVBhUW1nZVlkbFVyZndvaDRBZlhHT3pZSVMyQ3U5VA=="
109
+ self.BASIC_AUTHORIZATION: str = (
110
+ "Basic OGFjYjc3OGEtYjkxOC00YThkLTg2MjQtNzNhMGJlYjY0Mjg5OjdTY01NbTZmRVlYZGlFUEN4YVBhUW1nZVlkbFVyZndvaDRBZlhHT3pZSVMyQ3U5VA=="
111
+ )
108
112
  elif BRANDS[brand] == BRAND_HYUNDAI:
109
113
  self.BASE_URL: str = "au-apigw.ccs.hyundai.com.au:8080"
110
114
  self.CCSP_SERVICE_ID: str = "855c72df-dfd7-4230-ab03-67cbf902bb1c"
111
115
  self.APP_ID: str = "f9ccfdac-a48d-4c57-bd32-9116963c24ed" # Android app ID
112
- self.BASIC_AUTHORIZATION: str = "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="
116
+ self.BASIC_AUTHORIZATION: str = (
117
+ "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="
118
+ )
113
119
 
114
120
  self.USER_API_URL: str = "https://" + self.BASE_URL + "/api/v1/user/"
115
121
  self.SPA_API_URL: str = "https://" + self.BASE_URL + "/api/v1/spa/"
@@ -225,11 +231,10 @@ class KiaUvoApiAU(ApiImpl):
225
231
  if int(value) > 1260:
226
232
  value = dt.datetime.strptime(str(value), "%H%M").time()
227
233
  else:
228
- if timesection == 0:
229
- value = str(value) + " AM"
230
- elif timesection == 1:
231
- value = str(value) + " PM"
232
- value = dt.datetime.strptime(value, "%I%M %p").time()
234
+ d = dt.datetime.strptime(str(value), "%I%M")
235
+ if timesection > 0:
236
+ d += dt.timedelta(hours=12)
237
+ value = d.time()
233
238
  return value
234
239
 
235
240
  def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.17.0
3
+ Version: 3.17.2
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/fuatakgun/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -44,6 +44,6 @@ setup(
44
44
  test_suite="tests",
45
45
  tests_require=test_requirements,
46
46
  url="https://github.com/fuatakgun/hyundai_kia_connect_api",
47
- version="3.17.0",
47
+ version="3.17.2",
48
48
  zip_safe=False,
49
49
  )