hyundai-kia-connect-api 3.32.16__py2.py3-none-any.whl → 3.33.1__py2.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.
- hyundai_kia_connect_api/ApiImpl.py +46 -30
- hyundai_kia_connect_api/ApiImplType1.py +123 -0
- hyundai_kia_connect_api/KiaUvoApiAU.py +1 -68
- hyundai_kia_connect_api/KiaUvoApiEU.py +1 -114
- hyundai_kia_connect_api/VehicleManager.py +9 -1
- hyundai_kia_connect_api/const.py +4 -0
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/METADATA +11 -1
- hyundai_kia_connect_api-3.33.1.dist-info/RECORD +23 -0
- hyundai_kia_connect_api-3.32.16.dist-info/RECORD +0 -23
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/WHEEL +0 -0
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/entry_points.txt +0 -0
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/licenses/AUTHORS.rst +0 -0
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/licenses/LICENSE +0 -0
- {hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,15 @@
|
|
1
1
|
"""ApiImpl.py"""
|
2
2
|
|
3
3
|
# pylint:disable=unnecessary-pass,missing-class-docstring,invalid-name,missing-function-docstring,wildcard-import,unused-wildcard-import,unused-argument,missing-timeout,logging-fstring-interpolation
|
4
|
+
from .utils import get_child_value
|
5
|
+
|
4
6
|
|
5
7
|
import datetime as dt
|
6
8
|
import logging
|
7
9
|
from dataclasses import dataclass
|
8
10
|
|
9
11
|
import requests
|
12
|
+
from geopy.geocoders import GoogleV3
|
10
13
|
from requests.exceptions import JSONDecodeError
|
11
14
|
from .Token import Token
|
12
15
|
from .Vehicle import Vehicle
|
@@ -17,8 +20,10 @@ from .const import (
|
|
17
20
|
DOMAIN,
|
18
21
|
VALET_MODE_ACTION,
|
19
22
|
VEHICLE_LOCK_ACTION,
|
23
|
+
GEO_LOCATION_PROVIDERS,
|
24
|
+
OPENSTREETMAP,
|
25
|
+
GOOGLE,
|
20
26
|
)
|
21
|
-
from .utils import get_child_value
|
22
27
|
|
23
28
|
_LOGGER = logging.getLogger(__name__)
|
24
29
|
|
@@ -109,38 +114,49 @@ class ApiImpl:
|
|
109
114
|
pass
|
110
115
|
|
111
116
|
def update_geocoded_location(
|
112
|
-
self,
|
117
|
+
self,
|
118
|
+
token: Token,
|
119
|
+
vehicle: Vehicle,
|
120
|
+
use_email: bool,
|
121
|
+
provider: int = 1,
|
122
|
+
API_KEY: str = None,
|
113
123
|
) -> None:
|
114
124
|
if vehicle.location_latitude and vehicle.location_longitude:
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
headers = {"user-agent": "curl/7.81.0"}
|
128
|
-
_LOGGER.debug(
|
129
|
-
f"{DOMAIN} - Running update geocode location with value: {url}"
|
130
|
-
)
|
131
|
-
response = requests.get(url, headers=headers)
|
132
|
-
_LOGGER.debug(f"{DOMAIN} - geocode location raw response: {response}")
|
133
|
-
try:
|
134
|
-
response = response.json()
|
135
|
-
except JSONDecodeError:
|
136
|
-
_LOGGER.debug(f"{DOMAIN} - failed to decode json for geocode location")
|
137
|
-
vehicle.geocode = None
|
138
|
-
else:
|
139
|
-
_LOGGER.debug(f"{DOMAIN} - geocode location json response: {response}")
|
140
|
-
vehicle.geocode = (
|
141
|
-
get_child_value(response, "display_name"),
|
142
|
-
get_child_value(response, "address"),
|
125
|
+
if GEO_LOCATION_PROVIDERS[provider] == OPENSTREETMAP:
|
126
|
+
email_parameter = ""
|
127
|
+
if use_email is True:
|
128
|
+
email_parameter = "&email=" + token.username
|
129
|
+
|
130
|
+
url = (
|
131
|
+
"https://nominatim.openstreetmap.org/reverse?lat="
|
132
|
+
+ str(vehicle.location_latitude)
|
133
|
+
+ "&lon="
|
134
|
+
+ str(vehicle.location_longitude)
|
135
|
+
+ "&format=json&addressdetails=1&zoom=18"
|
136
|
+
+ email_parameter
|
143
137
|
)
|
138
|
+
headers = {"user-agent": "curl/7.81.0"}
|
139
|
+
_LOGGER.debug(f"{DOMAIN} - Running update geocode location")
|
140
|
+
response = requests.get(url, headers=headers)
|
141
|
+
try:
|
142
|
+
response = response.json()
|
143
|
+
except JSONDecodeError:
|
144
|
+
_LOGGER.debug(
|
145
|
+
f"{DOMAIN} - failed to decode json for geocode location"
|
146
|
+
)
|
147
|
+
vehicle.geocode = None
|
148
|
+
else:
|
149
|
+
vehicle.geocode = (
|
150
|
+
get_child_value(response, "display_name"),
|
151
|
+
get_child_value(response, "address"),
|
152
|
+
)
|
153
|
+
elif GEO_LOCATION_PROVIDERS[provider] == GOOGLE:
|
154
|
+
if API_KEY:
|
155
|
+
latlong = (vehicle.location_latitude, vehicle.location_longitude)
|
156
|
+
geolocator = GoogleV3(api_key=API_KEY)
|
157
|
+
locations = geolocator.reverse(latlong)
|
158
|
+
if locations:
|
159
|
+
vehicle.geocode = locations
|
144
160
|
|
145
161
|
def lock_action(
|
146
162
|
self, token: Token, vehicle: Vehicle, action: VEHICLE_LOCK_ACTION
|
@@ -1,6 +1,8 @@
|
|
1
1
|
"""ApiImplType1.py"""
|
2
2
|
|
3
3
|
import datetime as dt
|
4
|
+
import requests
|
5
|
+
import logging
|
4
6
|
from typing import Optional
|
5
7
|
|
6
8
|
from .ApiImpl import (
|
@@ -15,14 +17,70 @@ from .utils import (
|
|
15
17
|
)
|
16
18
|
|
17
19
|
from .const import (
|
20
|
+
DOMAIN,
|
18
21
|
DISTANCE_UNITS,
|
19
22
|
ENGINE_TYPES,
|
20
23
|
SEAT_STATUS,
|
21
24
|
TEMPERATURE_UNITS,
|
22
25
|
)
|
23
26
|
|
27
|
+
from .exceptions import (
|
28
|
+
APIError,
|
29
|
+
DuplicateRequestError,
|
30
|
+
RequestTimeoutError,
|
31
|
+
ServiceTemporaryUnavailable,
|
32
|
+
NoDataFound,
|
33
|
+
InvalidAPIResponseError,
|
34
|
+
RateLimitingError,
|
35
|
+
DeviceIDError,
|
36
|
+
)
|
37
|
+
|
24
38
|
USER_AGENT_OK_HTTP: str = "okhttp/3.12.0"
|
25
39
|
|
40
|
+
_LOGGER = logging.getLogger(__name__)
|
41
|
+
|
42
|
+
|
43
|
+
def _check_response_for_errors(response: dict) -> None:
|
44
|
+
"""
|
45
|
+
Checks for errors in the API response.
|
46
|
+
If an error is found, an exception is raised.
|
47
|
+
retCode known values:
|
48
|
+
- S: success
|
49
|
+
- F: failure
|
50
|
+
resCode / resMsg known values:
|
51
|
+
- 0000: no error
|
52
|
+
- 4002: "Invalid request body - invalid deviceId",
|
53
|
+
relogin will resolve but a bandaid.
|
54
|
+
- 4004: "Duplicate request"
|
55
|
+
- 4081: "Request timeout"
|
56
|
+
- 5031: "Unavailable remote control - Service Temporary Unavailable"
|
57
|
+
- 5091: "Exceeds number of requests"
|
58
|
+
- 5921: "No Data Found v2 - No Data Found v2"
|
59
|
+
- 9999: "Undefined Error - Response timeout"
|
60
|
+
:param response: the API's JSON response
|
61
|
+
"""
|
62
|
+
|
63
|
+
error_code_mapping = {
|
64
|
+
"4002": DeviceIDError,
|
65
|
+
"4004": DuplicateRequestError,
|
66
|
+
"4081": RequestTimeoutError,
|
67
|
+
"5031": ServiceTemporaryUnavailable,
|
68
|
+
"5091": RateLimitingError,
|
69
|
+
"5921": NoDataFound,
|
70
|
+
"9999": RequestTimeoutError,
|
71
|
+
}
|
72
|
+
|
73
|
+
if not any(x in response for x in ["retCode", "resCode", "resMsg"]):
|
74
|
+
_LOGGER.error(f"Unknown API response format: {response}")
|
75
|
+
raise InvalidAPIResponseError()
|
76
|
+
|
77
|
+
if response["retCode"] == "F":
|
78
|
+
if response["resCode"] in error_code_mapping:
|
79
|
+
raise error_code_mapping[response["resCode"]](response["resMsg"])
|
80
|
+
raise APIError(
|
81
|
+
f"Server returned: '{response['resCode']}' '{response['resMsg']}'"
|
82
|
+
)
|
83
|
+
|
26
84
|
|
27
85
|
class ApiImplType1(ApiImpl):
|
28
86
|
"""ApiImplType1"""
|
@@ -319,3 +377,68 @@ class ApiImplType1(ApiImpl):
|
|
319
377
|
)
|
320
378
|
|
321
379
|
vehicle.data = state
|
380
|
+
|
381
|
+
def start_charge(self, token: Token, vehicle: Vehicle) -> str:
|
382
|
+
if not vehicle.ccu_ccs2_protocol_support:
|
383
|
+
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
384
|
+
|
385
|
+
payload = {"action": "start", "deviceId": token.device_id}
|
386
|
+
headers = self._get_authenticated_headers(
|
387
|
+
token, vehicle.ccu_ccs2_protocol_support
|
388
|
+
)
|
389
|
+
|
390
|
+
else:
|
391
|
+
url = (
|
392
|
+
self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/charge"
|
393
|
+
)
|
394
|
+
|
395
|
+
payload = {"command": "start"}
|
396
|
+
headers = self._get_control_headers(token, vehicle)
|
397
|
+
|
398
|
+
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Request: {payload}")
|
399
|
+
response = requests.post(url, json=payload, headers=headers).json()
|
400
|
+
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Response: {response}")
|
401
|
+
_check_response_for_errors(response)
|
402
|
+
token.device_id = self._get_device_id(self._get_stamp())
|
403
|
+
return response["msgId"]
|
404
|
+
|
405
|
+
def stop_charge(self, token: Token, vehicle: Vehicle) -> str:
|
406
|
+
if not vehicle.ccu_ccs2_protocol_support:
|
407
|
+
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
408
|
+
|
409
|
+
payload = {"action": "stop", "deviceId": token.device_id}
|
410
|
+
headers = self._get_authenticated_headers(
|
411
|
+
token, vehicle.ccu_ccs2_protocol_support
|
412
|
+
)
|
413
|
+
|
414
|
+
else:
|
415
|
+
url = (
|
416
|
+
self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/charge"
|
417
|
+
)
|
418
|
+
|
419
|
+
payload = {"command": "stop"}
|
420
|
+
headers = self._get_control_headers(token, vehicle)
|
421
|
+
|
422
|
+
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Request: {payload}")
|
423
|
+
response = requests.post(url, json=payload, headers=headers).json()
|
424
|
+
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Response: {response}")
|
425
|
+
_check_response_for_errors(response)
|
426
|
+
token.device_id = self._get_device_id(self._get_stamp())
|
427
|
+
return response["msgId"]
|
428
|
+
|
429
|
+
def set_charging_current(self, token: Token, vehicle: Vehicle, level: int) -> str:
|
430
|
+
url = (
|
431
|
+
self.SPA_API_URL + "vehicles/" + vehicle.id + "/ccs2/charge/chargingcurrent"
|
432
|
+
)
|
433
|
+
|
434
|
+
body = {"chargingCurrent": level}
|
435
|
+
response = requests.post(
|
436
|
+
url,
|
437
|
+
json=body,
|
438
|
+
headers=self._get_authenticated_headers(
|
439
|
+
token, vehicle.ccu_ccs2_protocol_support
|
440
|
+
),
|
441
|
+
).json()
|
442
|
+
_LOGGER.debug(f"{DOMAIN} - Set Charging Current Response: {response}")
|
443
|
+
_check_response_for_errors(response)
|
444
|
+
return response["msgId"]
|
@@ -29,6 +29,7 @@ from .Vehicle import (
|
|
29
29
|
TripInfo,
|
30
30
|
DayTripCounts,
|
31
31
|
)
|
32
|
+
from .ApiImplType1 import _check_response_for_errors
|
32
33
|
from .const import (
|
33
34
|
BRAND_HYUNDAI,
|
34
35
|
BRAND_KIA,
|
@@ -44,13 +45,7 @@ from .const import (
|
|
44
45
|
)
|
45
46
|
from .exceptions import (
|
46
47
|
AuthenticationError,
|
47
|
-
DuplicateRequestError,
|
48
|
-
RequestTimeoutError,
|
49
|
-
ServiceTemporaryUnavailable,
|
50
|
-
NoDataFound,
|
51
|
-
InvalidAPIResponseError,
|
52
48
|
APIError,
|
53
|
-
RateLimitingError,
|
54
49
|
)
|
55
50
|
from .utils import (
|
56
51
|
get_child_value,
|
@@ -65,44 +60,6 @@ USER_AGENT_OK_HTTP: str = "okhttp/3.12.0"
|
|
65
60
|
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
|
66
61
|
|
67
62
|
|
68
|
-
def _check_response_for_errors(response: dict) -> None:
|
69
|
-
"""
|
70
|
-
Checks for errors in the API response.
|
71
|
-
If an error is found, an exception is raised.
|
72
|
-
retCode known values:
|
73
|
-
- S: success
|
74
|
-
- F: failure
|
75
|
-
resCode / resMsg known values:
|
76
|
-
- 0000: no error
|
77
|
-
- 4004: "Duplicate request"
|
78
|
-
- 4081: "Request timeout"
|
79
|
-
- 5031: "Unavailable remote control - Service Temporary Unavailable"
|
80
|
-
- 5091: "Exceeds number of requests"
|
81
|
-
- 5921: "No Data Found v2 - No Data Found v2"
|
82
|
-
- 9999: "Undefined Error - Response timeout"
|
83
|
-
:param response: the API's JSON response
|
84
|
-
"""
|
85
|
-
|
86
|
-
error_code_mapping = {
|
87
|
-
"4004": DuplicateRequestError,
|
88
|
-
"4081": RequestTimeoutError,
|
89
|
-
"5031": ServiceTemporaryUnavailable,
|
90
|
-
"5091": RateLimitingError,
|
91
|
-
"5921": NoDataFound,
|
92
|
-
"9999": RequestTimeoutError,
|
93
|
-
}
|
94
|
-
|
95
|
-
if not any(x in response for x in ["retCode", "resCode", "resMsg"]):
|
96
|
-
_LOGGER.error(f"Unknown API response format: {response}")
|
97
|
-
raise InvalidAPIResponseError()
|
98
|
-
|
99
|
-
if response["retCode"] == "F":
|
100
|
-
if response["resCode"] in error_code_mapping:
|
101
|
-
raise error_code_mapping[response["resCode"]](response["resMsg"])
|
102
|
-
else:
|
103
|
-
raise APIError(f"Server returned: '{response['resMsg']}'")
|
104
|
-
|
105
|
-
|
106
63
|
class KiaUvoApiAU(ApiImplType1):
|
107
64
|
data_timezone = tz.gettz("Australia/Sydney")
|
108
65
|
temperature_range = [x * 0.5 for x in range(34, 54)]
|
@@ -783,30 +740,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
783
740
|
_check_response_for_errors(response)
|
784
741
|
return response["msgId"]
|
785
742
|
|
786
|
-
def start_charge(self, token: Token, vehicle: Vehicle) -> str:
|
787
|
-
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
788
|
-
|
789
|
-
payload = {"action": "start", "deviceId": token.device_id}
|
790
|
-
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Request: {payload}")
|
791
|
-
response = requests.post(
|
792
|
-
url, json=payload, headers=self._get_control_headers(token)
|
793
|
-
).json()
|
794
|
-
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Response: {response}")
|
795
|
-
_check_response_for_errors(response)
|
796
|
-
return response["msgId"]
|
797
|
-
|
798
|
-
def stop_charge(self, token: Token, vehicle: Vehicle) -> str:
|
799
|
-
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
800
|
-
|
801
|
-
payload = {"action": "stop", "deviceId": token.device_id}
|
802
|
-
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Request {payload}")
|
803
|
-
response = requests.post(
|
804
|
-
url, json=payload, headers=self._get_control_headers(token)
|
805
|
-
).json()
|
806
|
-
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Response: {response}")
|
807
|
-
_check_response_for_errors(response)
|
808
|
-
return response["msgId"]
|
809
|
-
|
810
743
|
def _get_charge_limits(self, token: Token, vehicle: Vehicle) -> dict:
|
811
744
|
# Not currently used as value is in the general get.
|
812
745
|
# Most likely this forces the car the update it.
|
@@ -21,6 +21,7 @@ from .ApiImpl import (
|
|
21
21
|
ScheduleChargingClimateRequestOptions,
|
22
22
|
)
|
23
23
|
from .ApiImplType1 import ApiImplType1
|
24
|
+
from .ApiImplType1 import _check_response_for_errors
|
24
25
|
|
25
26
|
from .Token import Token
|
26
27
|
from .Vehicle import (
|
@@ -49,14 +50,7 @@ from .const import (
|
|
49
50
|
)
|
50
51
|
from .exceptions import (
|
51
52
|
AuthenticationError,
|
52
|
-
DuplicateRequestError,
|
53
|
-
RequestTimeoutError,
|
54
|
-
ServiceTemporaryUnavailable,
|
55
|
-
NoDataFound,
|
56
|
-
InvalidAPIResponseError,
|
57
53
|
APIError,
|
58
|
-
RateLimitingError,
|
59
|
-
DeviceIDError,
|
60
54
|
)
|
61
55
|
from .utils import (
|
62
56
|
get_child_value,
|
@@ -90,48 +84,6 @@ SUPPORTED_LANGUAGES_LIST = [
|
|
90
84
|
]
|
91
85
|
|
92
86
|
|
93
|
-
def _check_response_for_errors(response: dict) -> None:
|
94
|
-
"""
|
95
|
-
Checks for errors in the API response.
|
96
|
-
If an error is found, an exception is raised.
|
97
|
-
retCode known values:
|
98
|
-
- S: success
|
99
|
-
- F: failure
|
100
|
-
resCode / resMsg known values:
|
101
|
-
- 0000: no error
|
102
|
-
- 4002: "Invalid request body - invalid deviceId",
|
103
|
-
relogin will resolve but a bandaid.
|
104
|
-
- 4004: "Duplicate request"
|
105
|
-
- 4081: "Request timeout"
|
106
|
-
- 5031: "Unavailable remote control - Service Temporary Unavailable"
|
107
|
-
- 5091: "Exceeds number of requests"
|
108
|
-
- 5921: "No Data Found v2 - No Data Found v2"
|
109
|
-
- 9999: "Undefined Error - Response timeout"
|
110
|
-
:param response: the API's JSON response
|
111
|
-
"""
|
112
|
-
|
113
|
-
error_code_mapping = {
|
114
|
-
"4002": DeviceIDError,
|
115
|
-
"4004": DuplicateRequestError,
|
116
|
-
"4081": RequestTimeoutError,
|
117
|
-
"5031": ServiceTemporaryUnavailable,
|
118
|
-
"5091": RateLimitingError,
|
119
|
-
"5921": NoDataFound,
|
120
|
-
"9999": RequestTimeoutError,
|
121
|
-
}
|
122
|
-
|
123
|
-
if not any(x in response for x in ["retCode", "resCode", "resMsg"]):
|
124
|
-
_LOGGER.error(f"Unknown API response format: {response}")
|
125
|
-
raise InvalidAPIResponseError()
|
126
|
-
|
127
|
-
if response["retCode"] == "F":
|
128
|
-
if response["resCode"] in error_code_mapping:
|
129
|
-
raise error_code_mapping[response["resCode"]](response["resMsg"])
|
130
|
-
raise APIError(
|
131
|
-
f"Server returned: '{response['resCode']}' '{response['resMsg']}'"
|
132
|
-
)
|
133
|
-
|
134
|
-
|
135
87
|
class KiaUvoApiEU(ApiImplType1):
|
136
88
|
data_timezone = tz.gettz("Europe/Berlin")
|
137
89
|
temperature_range = [x * 0.5 for x in range(28, 60)]
|
@@ -1013,54 +965,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1013
965
|
token.device_id = self._get_device_id(self._get_stamp())
|
1014
966
|
return response["msgId"]
|
1015
967
|
|
1016
|
-
def start_charge(self, token: Token, vehicle: Vehicle) -> str:
|
1017
|
-
if not vehicle.ccu_ccs2_protocol_support:
|
1018
|
-
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
1019
|
-
|
1020
|
-
payload = {"action": "start", "deviceId": token.device_id}
|
1021
|
-
headers = self._get_authenticated_headers(
|
1022
|
-
token, vehicle.ccu_ccs2_protocol_support
|
1023
|
-
)
|
1024
|
-
|
1025
|
-
else:
|
1026
|
-
url = (
|
1027
|
-
self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/charge"
|
1028
|
-
)
|
1029
|
-
|
1030
|
-
payload = {"command": "start"}
|
1031
|
-
headers = self._get_control_headers(token, vehicle)
|
1032
|
-
|
1033
|
-
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Request: {payload}")
|
1034
|
-
response = requests.post(url, json=payload, headers=headers).json()
|
1035
|
-
_LOGGER.debug(f"{DOMAIN} - Start Charge Action Response: {response}")
|
1036
|
-
_check_response_for_errors(response)
|
1037
|
-
token.device_id = self._get_device_id(self._get_stamp())
|
1038
|
-
return response["msgId"]
|
1039
|
-
|
1040
|
-
def stop_charge(self, token: Token, vehicle: Vehicle) -> str:
|
1041
|
-
if not vehicle.ccu_ccs2_protocol_support:
|
1042
|
-
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/control/charge"
|
1043
|
-
|
1044
|
-
payload = {"action": "stop", "deviceId": token.device_id}
|
1045
|
-
headers = self._get_authenticated_headers(
|
1046
|
-
token, vehicle.ccu_ccs2_protocol_support
|
1047
|
-
)
|
1048
|
-
|
1049
|
-
else:
|
1050
|
-
url = (
|
1051
|
-
self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/charge"
|
1052
|
-
)
|
1053
|
-
|
1054
|
-
payload = {"command": "stop"}
|
1055
|
-
headers = self._get_control_headers(token, vehicle)
|
1056
|
-
|
1057
|
-
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Request: {payload}")
|
1058
|
-
response = requests.post(url, json=payload, headers=headers).json()
|
1059
|
-
_LOGGER.debug(f"{DOMAIN} - Stop Charge Action Response: {response}")
|
1060
|
-
_check_response_for_errors(response)
|
1061
|
-
token.device_id = self._get_device_id(self._get_stamp())
|
1062
|
-
return response["msgId"]
|
1063
|
-
|
1064
968
|
def start_hazard_lights(self, token: Token, vehicle: Vehicle) -> str:
|
1065
969
|
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/light"
|
1066
970
|
|
@@ -1330,23 +1234,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1330
1234
|
_check_response_for_errors(response)
|
1331
1235
|
return response["msgId"]
|
1332
1236
|
|
1333
|
-
def set_charging_current(self, token: Token, vehicle: Vehicle, level: int) -> str:
|
1334
|
-
url = (
|
1335
|
-
self.SPA_API_URL + "vehicles/" + vehicle.id + "/ccs2/charge/chargingcurrent"
|
1336
|
-
)
|
1337
|
-
|
1338
|
-
body = {"chargingCurrent": level}
|
1339
|
-
response = requests.post(
|
1340
|
-
url,
|
1341
|
-
json=body,
|
1342
|
-
headers=self._get_authenticated_headers(
|
1343
|
-
token, vehicle.ccu_ccs2_protocol_support
|
1344
|
-
),
|
1345
|
-
).json()
|
1346
|
-
_LOGGER.debug(f"{DOMAIN} - Set Charging Current Response: {response}")
|
1347
|
-
_check_response_for_errors(response)
|
1348
|
-
return response["msgId"]
|
1349
|
-
|
1350
1237
|
def schedule_charging_and_climate(
|
1351
1238
|
self,
|
1352
1239
|
token: Token,
|
@@ -53,6 +53,8 @@ class VehicleManager:
|
|
53
53
|
pin: str,
|
54
54
|
geocode_api_enable: bool = False,
|
55
55
|
geocode_api_use_email: bool = False,
|
56
|
+
geocode_provider: int = 1,
|
57
|
+
geocode_api_key: str = None,
|
56
58
|
language: str = "en",
|
57
59
|
):
|
58
60
|
self.region: int = region
|
@@ -61,8 +63,10 @@ class VehicleManager:
|
|
61
63
|
self.password: str = password
|
62
64
|
self.geocode_api_enable: bool = geocode_api_enable
|
63
65
|
self.geocode_api_use_email: bool = geocode_api_use_email
|
66
|
+
self.geocode_provider: int = geocode_provider
|
64
67
|
self.pin: str = pin
|
65
68
|
self.language: str = language
|
69
|
+
self.geocode_api_key: str = geocode_api_key
|
66
70
|
|
67
71
|
self.api: ApiImpl = self.get_implementation_by_region_brand(
|
68
72
|
self.region, self.brand, self.language
|
@@ -91,7 +95,11 @@ class VehicleManager:
|
|
91
95
|
self.api.update_vehicle_with_cached_state(self.token, vehicle)
|
92
96
|
if self.geocode_api_enable is True:
|
93
97
|
self.api.update_geocoded_location(
|
94
|
-
self.token,
|
98
|
+
token=self.token,
|
99
|
+
vehicle=vehicle,
|
100
|
+
use_email=self.geocode_api_use_email,
|
101
|
+
provider=self.geocode_provider,
|
102
|
+
API_KEY=self.geocode_api_key,
|
95
103
|
)
|
96
104
|
else:
|
97
105
|
_LOGGER.debug(f"{DOMAIN} - Vehicle Disabled, skipping.")
|
hyundai_kia_connect_api/const.py
CHANGED
@@ -12,6 +12,10 @@ BRAND_HYUNDAI = "Hyundai"
|
|
12
12
|
BRAND_GENESIS = "Genesis"
|
13
13
|
BRANDS = {1: BRAND_KIA, 2: BRAND_HYUNDAI, 3: BRAND_GENESIS}
|
14
14
|
|
15
|
+
GOOGLE = "google"
|
16
|
+
OPENSTREETMAP = "openstreetmap"
|
17
|
+
GEO_LOCATION_PROVIDERS = {1: OPENSTREETMAP, 2: GOOGLE}
|
18
|
+
|
15
19
|
REGION_EUROPE = "Europe"
|
16
20
|
REGION_CANADA = "Canada"
|
17
21
|
REGION_USA = "USA"
|
{hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyundai_kia_connect_api
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.33.1
|
4
4
|
Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
|
5
5
|
Home-page: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api
|
6
6
|
Author: Fuat Akgun
|
@@ -20,6 +20,7 @@ Requires-Dist: curlify>=2.2.1
|
|
20
20
|
Requires-Dist: python-dateutil
|
21
21
|
Requires-Dist: pytz>=2021.3
|
22
22
|
Requires-Dist: certifi>=2024.6.2
|
23
|
+
Requires-Dist: geopy>=2.2.0
|
23
24
|
Dynamic: author
|
24
25
|
Dynamic: author-email
|
25
26
|
Dynamic: classifier
|
@@ -60,10 +61,19 @@ Python 3.10 or newer is required to use this package. Vehicle manager is the key
|
|
60
61
|
password: str
|
61
62
|
pin: str (required for CA, and potentially USA, otherwise pass a blank string)
|
62
63
|
|
64
|
+
Optional parameters are::
|
65
|
+
geocode_api_enable: bool
|
66
|
+
geocode_api_use_email: bool
|
67
|
+
geocode_provider: int
|
68
|
+
geocode_api_key: str
|
69
|
+
language: str
|
70
|
+
|
63
71
|
Key values for the int exist in the `const.py <https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/const.py>`_ file as::
|
64
72
|
|
65
73
|
REGIONS = {1: REGION_EUROPE, 2: REGION_CANADA, 3: REGION_USA, 4: REGION_CHINA, 5: REGION_AUSTRALIA}
|
66
74
|
BRANDS = {1: BRAND_KIA, 2: BRAND_HYUNDAI, 3: BRAND_GENESIS}
|
75
|
+
GEO_LOCATION_PROVIDERS = {1: OPENSTREETMAP, 2: GOOGLE}
|
76
|
+
|
67
77
|
|
68
78
|
Once this is done you can now make the following calls against the vehicle manager::
|
69
79
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
hyundai_kia_connect_api/ApiImpl.py,sha256=PuK3dID01qTGB6aGtQY4uf1hF-t4d03wUzG_gUFn_1g,8353
|
2
|
+
hyundai_kia_connect_api/ApiImplType1.py,sha256=V2rieKKPhR-92E4_0N6wKFEupab5OgAaKxHxB5OKVi4,16587
|
3
|
+
hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
|
4
|
+
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=0QmWLeLa6RL3tKrCLOfemhVDmC8pdsxykdNd_C1DHLg,45945
|
5
|
+
hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=XBya0yHZ2MC3TBVQLSc6N-SzmGt_s3l4nGVyNgmjl9Q,32514
|
6
|
+
hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
|
7
|
+
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=RuPWWsyEYP4xYPH5YTNnC2Vzgkm0tB9PE9Ar2wK2v_M,67075
|
8
|
+
hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=8DP7iOORHtU98LipcAYEPdtJvubBlUP2-jlDxAhTDhQ,30548
|
9
|
+
hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
|
10
|
+
hyundai_kia_connect_api/Vehicle.py,sha256=hZT0wU7-mMi85bgqNHMu6CyhQQ5h-Jfmoc1ce2uPhYM,18867
|
11
|
+
hyundai_kia_connect_api/VehicleManager.py,sha256=k2MZR6nuPPrH1G9cLrukjYyDAar-M39qdNcQtl1ntPI,11512
|
12
|
+
hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
|
13
|
+
hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn-rYEjI,19730
|
14
|
+
hyundai_kia_connect_api/const.py,sha256=dXEh-lpthH8000nUXFoRZpQXkTxVHDAgDe_KqnSZhZw,2280
|
15
|
+
hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
|
16
|
+
hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
|
17
|
+
hyundai_kia_connect_api-3.33.1.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
|
18
|
+
hyundai_kia_connect_api-3.33.1.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
|
19
|
+
hyundai_kia_connect_api-3.33.1.dist-info/METADATA,sha256=q9Xdkya0cPSkYGagr8hL8l0P07KgHgi3ZLM5R--dpaU,7142
|
20
|
+
hyundai_kia_connect_api-3.33.1.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
21
|
+
hyundai_kia_connect_api-3.33.1.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
|
22
|
+
hyundai_kia_connect_api-3.33.1.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
|
23
|
+
hyundai_kia_connect_api-3.33.1.dist-info/RECORD,,
|
@@ -1,23 +0,0 @@
|
|
1
|
-
hyundai_kia_connect_api/ApiImpl.py,sha256=sgUXOcQnBMTVylxOLeqnYOGnz9KqLqRClRpE12u6ZS4,7806
|
2
|
-
hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
|
3
|
-
hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
|
4
|
-
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=tslh0gzvPBwYJmcWlf9B0l7PyYZdy2e7GqpRkl8_Svk,48471
|
5
|
-
hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=XBya0yHZ2MC3TBVQLSc6N-SzmGt_s3l4nGVyNgmjl9Q,32514
|
6
|
-
hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
|
7
|
-
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=TxgO2dfLjKSKfSkRMoTL_fbmzRFRPb8oJ9IDztD50Ug,71300
|
8
|
-
hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=8DP7iOORHtU98LipcAYEPdtJvubBlUP2-jlDxAhTDhQ,30548
|
9
|
-
hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
|
10
|
-
hyundai_kia_connect_api/Vehicle.py,sha256=hZT0wU7-mMi85bgqNHMu6CyhQQ5h-Jfmoc1ce2uPhYM,18867
|
11
|
-
hyundai_kia_connect_api/VehicleManager.py,sha256=SfGuCT0foCJqUNNLXs_9lRR5XGQ7xd-fodTIs3JEl0o,11167
|
12
|
-
hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
|
13
|
-
hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn-rYEjI,19730
|
14
|
-
hyundai_kia_connect_api/const.py,sha256=scBlhrMims0W6_pESVVdQz2uUxczg2cf2qDQ7avbhVo,2174
|
15
|
-
hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
|
16
|
-
hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
|
17
|
-
hyundai_kia_connect_api-3.32.16.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
|
18
|
-
hyundai_kia_connect_api-3.32.16.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
|
19
|
-
hyundai_kia_connect_api-3.32.16.dist-info/METADATA,sha256=RIBRaHq7nNQrdLcoy-Xm7VrI6UCBGwsKyohlRRv2ePY,6894
|
20
|
-
hyundai_kia_connect_api-3.32.16.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
21
|
-
hyundai_kia_connect_api-3.32.16.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
|
22
|
-
hyundai_kia_connect_api-3.32.16.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
|
23
|
-
hyundai_kia_connect_api-3.32.16.dist-info/RECORD,,
|
{hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.32.16.dist-info → hyundai_kia_connect_api-3.33.1.dist-info}/top_level.txt
RENAMED
File without changes
|