hyundai-kia-connect-api 3.33.1__py2.py3-none-any.whl → 3.33.3__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 +26 -12
- hyundai_kia_connect_api/ApiImplType1.py +10 -0
- hyundai_kia_connect_api/KiaUvoApiAU.py +6 -14
- hyundai_kia_connect_api/KiaUvoApiEU.py +0 -10
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/METADATA +1 -1
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/RECORD +11 -11
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/WHEEL +0 -0
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/entry_points.txt +0 -0
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/licenses/AUTHORS.rst +0 -0
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/licenses/LICENSE +0 -0
- {hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,6 @@
|
|
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
|
-
|
6
|
-
|
7
4
|
import datetime as dt
|
8
5
|
import logging
|
9
6
|
from dataclasses import dataclass
|
@@ -11,6 +8,8 @@ from dataclasses import dataclass
|
|
11
8
|
import requests
|
12
9
|
from geopy.geocoders import GoogleV3
|
13
10
|
from requests.exceptions import JSONDecodeError
|
11
|
+
|
12
|
+
from .utils import get_child_value
|
14
13
|
from .Token import Token
|
15
14
|
from .Vehicle import Vehicle
|
16
15
|
from .const import (
|
@@ -73,6 +72,8 @@ class ScheduleChargingClimateRequestOptions:
|
|
73
72
|
class ApiImpl:
|
74
73
|
data_timezone = dt.timezone.utc
|
75
74
|
temperature_range = None
|
75
|
+
previous_latitude: float = None
|
76
|
+
previous_longitude: float = None
|
76
77
|
|
77
78
|
def __init__(self) -> None:
|
78
79
|
"""Initialize."""
|
@@ -122,7 +123,13 @@ class ApiImpl:
|
|
122
123
|
API_KEY: str = None,
|
123
124
|
) -> None:
|
124
125
|
if vehicle.location_latitude and vehicle.location_longitude:
|
125
|
-
if
|
126
|
+
if (
|
127
|
+
vehicle.geocode
|
128
|
+
and vehicle.location_latitude == self.previous_latitude
|
129
|
+
and vehicle.location_longitude == self.previous_longitude
|
130
|
+
): # previous coordinates are the same, so keep last valid vehicle.geocode
|
131
|
+
_LOGGER.debug(f"{DOMAIN} - Keeping last geocode location")
|
132
|
+
elif GEO_LOCATION_PROVIDERS[provider] == OPENSTREETMAP:
|
126
133
|
email_parameter = ""
|
127
134
|
if use_email is True:
|
128
135
|
email_parameter = "&email=" + token.username
|
@@ -136,27 +143,34 @@ class ApiImpl:
|
|
136
143
|
+ email_parameter
|
137
144
|
)
|
138
145
|
headers = {"user-agent": "curl/7.81.0"}
|
139
|
-
_LOGGER.debug(f"{DOMAIN} - Running update geocode location")
|
140
146
|
response = requests.get(url, headers=headers)
|
141
147
|
try:
|
142
148
|
response = response.json()
|
143
149
|
except JSONDecodeError:
|
144
|
-
_LOGGER.
|
145
|
-
f"{DOMAIN} - failed to decode json for geocode location"
|
146
|
-
)
|
150
|
+
_LOGGER.warning(f"{DOMAIN} - failed geocode openstreetmap")
|
147
151
|
vehicle.geocode = None
|
148
152
|
else:
|
149
153
|
vehicle.geocode = (
|
150
154
|
get_child_value(response, "display_name"),
|
151
155
|
get_child_value(response, "address"),
|
152
156
|
)
|
157
|
+
self.previous_latitude = vehicle.location_latitude
|
158
|
+
self.previous_longitude = vehicle.location_longitude
|
159
|
+
_LOGGER.debug(f"{DOMAIN} - geocode openstreetmap")
|
153
160
|
elif GEO_LOCATION_PROVIDERS[provider] == GOOGLE:
|
154
161
|
if API_KEY:
|
155
162
|
latlong = (vehicle.location_latitude, vehicle.location_longitude)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
163
|
+
try:
|
164
|
+
geolocator = GoogleV3(api_key=API_KEY)
|
165
|
+
locations = geolocator.reverse(latlong)
|
166
|
+
if locations:
|
167
|
+
vehicle.geocode = locations
|
168
|
+
self.previous_latitude = vehicle.location_latitude
|
169
|
+
self.previous_longitude = vehicle.location_longitude
|
170
|
+
_LOGGER.debug(f"{DOMAIN} - geocode google")
|
171
|
+
except Exception as ex: # pylint: disable=broad-except
|
172
|
+
_LOGGER.warning(f"{DOMAIN} - failed geocode Google: {ex}")
|
173
|
+
vehicle.geocode = None
|
160
174
|
|
161
175
|
def lock_action(
|
162
176
|
self, token: Token, vehicle: Vehicle, action: VEHICLE_LOCK_ACTION
|
@@ -104,6 +104,16 @@ class ApiImplType1(ApiImpl):
|
|
104
104
|
"User-Agent": USER_AGENT_OK_HTTP,
|
105
105
|
}
|
106
106
|
|
107
|
+
def _get_control_headers(self, token: Token, vehicle: Vehicle) -> dict:
|
108
|
+
control_token, _ = self._get_control_token(token)
|
109
|
+
authenticated_headers = self._get_authenticated_headers(
|
110
|
+
token, vehicle.ccu_ccs2_protocol_support
|
111
|
+
)
|
112
|
+
return authenticated_headers | {
|
113
|
+
"Authorization": control_token,
|
114
|
+
"AuthorizationCCSP": control_token,
|
115
|
+
}
|
116
|
+
|
107
117
|
def _update_vehicle_properties_ccs2(self, vehicle: Vehicle, state: dict) -> None:
|
108
118
|
if get_child_value(state, "Date"):
|
109
119
|
vehicle.last_updated_at = parse_datetime(
|
@@ -82,14 +82,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
82
82
|
self.SPA_API_URL_V2: str = "https://" + self.BASE_URL + "/api/v2/spa/"
|
83
83
|
self.CLIENT_ID: str = self.CCSP_SERVICE_ID
|
84
84
|
|
85
|
-
def _get_control_headers(self, token: Token) -> dict:
|
86
|
-
control_token, _ = self._get_control_token(token)
|
87
|
-
authenticated_headers = self._get_authenticated_headers(token)
|
88
|
-
return authenticated_headers | {
|
89
|
-
"Authorization": control_token,
|
90
|
-
"AuthorizationCCSP": control_token,
|
91
|
-
}
|
92
|
-
|
93
85
|
def login(self, username: str, password: str) -> Token:
|
94
86
|
stamp = self._get_stamp()
|
95
87
|
device_id = self._get_device_id(stamp)
|
@@ -647,7 +639,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
647
639
|
payload = {"action": action.value, "deviceId": token.device_id}
|
648
640
|
_LOGGER.debug(f"{DOMAIN} - Lock Action Request: {payload}")
|
649
641
|
response = requests.post(
|
650
|
-
url, json=payload, headers=self._get_control_headers(token)
|
642
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
651
643
|
).json()
|
652
644
|
_LOGGER.debug(f"{DOMAIN} - Lock Action Response: {response}")
|
653
645
|
_check_response_for_errors(response)
|
@@ -666,7 +658,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
666
658
|
}
|
667
659
|
_LOGGER.debug(f"{DOMAIN} - Window State Action Request: {payload}")
|
668
660
|
response = requests.post(
|
669
|
-
url, json=payload, headers=self._get_control_headers(token)
|
661
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
670
662
|
).json()
|
671
663
|
_LOGGER.debug(f"{DOMAIN} - Window State Action Response: {response}")
|
672
664
|
_check_response_for_errors(response)
|
@@ -681,7 +673,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
681
673
|
payload = {"action": action.value, "deviceId": token.device_id}
|
682
674
|
_LOGGER.debug(f"{DOMAIN} - Charge Port Action Request: {payload}")
|
683
675
|
response = requests.post(
|
684
|
-
url, json=payload, headers=self._get_control_headers(token)
|
676
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
685
677
|
).json()
|
686
678
|
_LOGGER.debug(f"{DOMAIN} - Charge Port Action Response: {response}")
|
687
679
|
_check_response_for_errors(response)
|
@@ -721,7 +713,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
721
713
|
}
|
722
714
|
_LOGGER.debug(f"{DOMAIN} - Start Climate Action Request: {payload}")
|
723
715
|
response = requests.post(
|
724
|
-
url, json=payload, headers=self._get_control_headers(token)
|
716
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
725
717
|
).json()
|
726
718
|
_LOGGER.debug(f"{DOMAIN} - Start Climate Action Response: {response}")
|
727
719
|
_check_response_for_errors(response)
|
@@ -734,7 +726,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
734
726
|
}
|
735
727
|
_LOGGER.debug(f"{DOMAIN} - Stop Climate Action Request: {payload}")
|
736
728
|
response = requests.post(
|
737
|
-
url, json=payload, headers=self._get_control_headers(token)
|
729
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
738
730
|
).json()
|
739
731
|
_LOGGER.debug(f"{DOMAIN} - Stop Climate Action Response: {response}")
|
740
732
|
_check_response_for_errors(response)
|
@@ -943,7 +935,7 @@ class KiaUvoApiAU(ApiImplType1):
|
|
943
935
|
]
|
944
936
|
}
|
945
937
|
response = requests.post(
|
946
|
-
url, json=body, headers=self._get_control_headers(token)
|
938
|
+
url, json=body, headers=self._get_control_headers(token, vehicle)
|
947
939
|
).json()
|
948
940
|
_LOGGER.debug(f"{DOMAIN} - Set Charge Limits Response: {response}")
|
949
941
|
_check_response_for_errors(response)
|
@@ -183,16 +183,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
183
183
|
+ "&state=$service_id:$user_id"
|
184
184
|
)
|
185
185
|
|
186
|
-
def _get_control_headers(self, token: Token, vehicle: Vehicle) -> dict:
|
187
|
-
control_token, _ = self._get_control_token(token)
|
188
|
-
authenticated_headers = self._get_authenticated_headers(
|
189
|
-
token, vehicle.ccu_ccs2_protocol_support
|
190
|
-
)
|
191
|
-
return authenticated_headers | {
|
192
|
-
"Authorization": control_token,
|
193
|
-
"AuthorizationCCSP": control_token,
|
194
|
-
}
|
195
|
-
|
196
186
|
def login(self, username: str, password: str) -> Token:
|
197
187
|
stamp = self._get_stamp()
|
198
188
|
device_id = self._get_device_id(stamp)
|
{hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyundai_kia_connect_api
|
3
|
-
Version: 3.33.
|
3
|
+
Version: 3.33.3
|
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
|
{hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/RECORD
RENAMED
@@ -1,10 +1,10 @@
|
|
1
|
-
hyundai_kia_connect_api/ApiImpl.py,sha256=
|
2
|
-
hyundai_kia_connect_api/ApiImplType1.py,sha256=
|
1
|
+
hyundai_kia_connect_api/ApiImpl.py,sha256=PUZfRVb_I3uC6KaY2HK4TxBFfXyVqaXAgGO1GOAb1Hc,9344
|
2
|
+
hyundai_kia_connect_api/ApiImplType1.py,sha256=6uSqZYWmFT08gH1OL1h7SJso3HvqH9GszSQzngQbWcc,16993
|
3
3
|
hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
|
4
|
-
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=
|
4
|
+
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=Ox-GXfu2h6dsAA1tgXRVDCYgMP5Hi9IHMXDBzmYzBxQ,45668
|
5
5
|
hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=XBya0yHZ2MC3TBVQLSc6N-SzmGt_s3l4nGVyNgmjl9Q,32514
|
6
6
|
hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
|
7
|
-
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=
|
7
|
+
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=G3sfyyHaAnUeoYWC3rOpyrw_FfOs9ZDOEGUJuRTkuBc,66669
|
8
8
|
hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=8DP7iOORHtU98LipcAYEPdtJvubBlUP2-jlDxAhTDhQ,30548
|
9
9
|
hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
|
10
10
|
hyundai_kia_connect_api/Vehicle.py,sha256=hZT0wU7-mMi85bgqNHMu6CyhQQ5h-Jfmoc1ce2uPhYM,18867
|
@@ -14,10 +14,10 @@ hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn
|
|
14
14
|
hyundai_kia_connect_api/const.py,sha256=dXEh-lpthH8000nUXFoRZpQXkTxVHDAgDe_KqnSZhZw,2280
|
15
15
|
hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
|
16
16
|
hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
|
17
|
-
hyundai_kia_connect_api-3.33.
|
18
|
-
hyundai_kia_connect_api-3.33.
|
19
|
-
hyundai_kia_connect_api-3.33.
|
20
|
-
hyundai_kia_connect_api-3.33.
|
21
|
-
hyundai_kia_connect_api-3.33.
|
22
|
-
hyundai_kia_connect_api-3.33.
|
23
|
-
hyundai_kia_connect_api-3.33.
|
17
|
+
hyundai_kia_connect_api-3.33.3.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
|
18
|
+
hyundai_kia_connect_api-3.33.3.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
|
19
|
+
hyundai_kia_connect_api-3.33.3.dist-info/METADATA,sha256=FGOXRnhGoB3Giy_-CSajQQTB39-CEiKBKSIZrfZOAZQ,7142
|
20
|
+
hyundai_kia_connect_api-3.33.3.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
21
|
+
hyundai_kia_connect_api-3.33.3.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
|
22
|
+
hyundai_kia_connect_api-3.33.3.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
|
23
|
+
hyundai_kia_connect_api-3.33.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.33.1.dist-info → hyundai_kia_connect_api-3.33.3.dist-info}/top_level.txt
RENAMED
File without changes
|