hyundai-kia-connect-api 3.33.2__py2.py3-none-any.whl → 3.33.4__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.
@@ -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 GEO_LOCATION_PROVIDERS[provider] == OPENSTREETMAP:
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.debug(
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
- geolocator = GoogleV3(api_key=API_KEY)
157
- locations = geolocator.reverse(latlong)
158
- if locations:
159
- vehicle.geocode = locations
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
@@ -452,3 +452,31 @@ class ApiImplType1(ApiImpl):
452
452
  _LOGGER.debug(f"{DOMAIN} - Set Charging Current Response: {response}")
453
453
  _check_response_for_errors(response)
454
454
  return response["msgId"]
455
+
456
+ def set_charge_limits(
457
+ self, token: Token, vehicle: Vehicle, ac: int, dc: int
458
+ ) -> str:
459
+ url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/charge/target"
460
+
461
+ body = {
462
+ "targetSOClist": [
463
+ {
464
+ "plugType": 0,
465
+ "targetSOClevel": dc,
466
+ },
467
+ {
468
+ "plugType": 1,
469
+ "targetSOClevel": ac,
470
+ },
471
+ ]
472
+ }
473
+ response = requests.post(
474
+ url,
475
+ json=body,
476
+ headers=self._get_authenticated_headers(
477
+ token, vehicle.ccu_ccs2_protocol_support
478
+ ),
479
+ ).json()
480
+ _LOGGER.debug(f"{DOMAIN} - Set Charge Limits Response: {response}")
481
+ _check_response_for_errors(response)
482
+ return response["msgId"]
@@ -917,30 +917,6 @@ class KiaUvoApiAU(ApiImplType1):
917
917
  )
918
918
  return None
919
919
 
920
- def set_charge_limits(
921
- self, token: Token, vehicle: Vehicle, ac: int, dc: int
922
- ) -> str:
923
- url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/charge/target"
924
-
925
- body = {
926
- "targetSOClist": [
927
- {
928
- "plugType": 0,
929
- "targetSOClevel": dc,
930
- },
931
- {
932
- "plugType": 1,
933
- "targetSOClevel": ac,
934
- },
935
- ]
936
- }
937
- response = requests.post(
938
- url, json=body, headers=self._get_control_headers(token, vehicle)
939
- ).json()
940
- _LOGGER.debug(f"{DOMAIN} - Set Charge Limits Response: {response}")
941
- _check_response_for_errors(response)
942
- return response["msgId"]
943
-
944
920
  def _get_stamp(self) -> str:
945
921
  if BRANDS[self.brand] == BRAND_KIA:
946
922
  cfb = base64.b64decode(
@@ -1196,34 +1196,6 @@ class KiaUvoApiEU(ApiImplType1):
1196
1196
  )
1197
1197
  return None
1198
1198
 
1199
- def set_charge_limits(
1200
- self, token: Token, vehicle: Vehicle, ac: int, dc: int
1201
- ) -> str:
1202
- url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/charge/target"
1203
-
1204
- body = {
1205
- "targetSOClist": [
1206
- {
1207
- "plugType": 0,
1208
- "targetSOClevel": dc,
1209
- },
1210
- {
1211
- "plugType": 1,
1212
- "targetSOClevel": ac,
1213
- },
1214
- ]
1215
- }
1216
- response = requests.post(
1217
- url,
1218
- json=body,
1219
- headers=self._get_authenticated_headers(
1220
- token, vehicle.ccu_ccs2_protocol_support
1221
- ),
1222
- ).json()
1223
- _LOGGER.debug(f"{DOMAIN} - Set Charge Limits Response: {response}")
1224
- _check_response_for_errors(response)
1225
- return response["msgId"]
1226
-
1227
1199
  def schedule_charging_and_climate(
1228
1200
  self,
1229
1201
  token: Token,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.33.2
3
+ Version: 3.33.4
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
@@ -1,10 +1,10 @@
1
- hyundai_kia_connect_api/ApiImpl.py,sha256=PuK3dID01qTGB6aGtQY4uf1hF-t4d03wUzG_gUFn_1g,8353
2
- hyundai_kia_connect_api/ApiImplType1.py,sha256=6uSqZYWmFT08gH1OL1h7SJso3HvqH9GszSQzngQbWcc,16993
1
+ hyundai_kia_connect_api/ApiImpl.py,sha256=PUZfRVb_I3uC6KaY2HK4TxBFfXyVqaXAgGO1GOAb1Hc,9344
2
+ hyundai_kia_connect_api/ApiImplType1.py,sha256=gvI9N9ZWyeqTe0xH82-RkqbeC8A3_kdSzbzz68ibkC0,17846
3
3
  hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
4
- hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=Ox-GXfu2h6dsAA1tgXRVDCYgMP5Hi9IHMXDBzmYzBxQ,45668
4
+ hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=c-JL4mhC-_-iH4fGMgV0YWha9xsC7Vo5wPneXsQ2S78,44902
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=G3sfyyHaAnUeoYWC3rOpyrw_FfOs9ZDOEGUJuRTkuBc,66669
7
+ hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=rfFIm_2guw3x7Blp8dr1uL7MT2fYVpHjxmwCRrlEXD0,65816
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.2.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
- hyundai_kia_connect_api-3.33.2.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
- hyundai_kia_connect_api-3.33.2.dist-info/METADATA,sha256=b0UCE6-Lvmy1zPUY-VPz0SYj8VolaQ7r7UeohiyYDdA,7142
20
- hyundai_kia_connect_api-3.33.2.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
21
- hyundai_kia_connect_api-3.33.2.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
- hyundai_kia_connect_api-3.33.2.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
- hyundai_kia_connect_api-3.33.2.dist-info/RECORD,,
17
+ hyundai_kia_connect_api-3.33.4.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
+ hyundai_kia_connect_api-3.33.4.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
+ hyundai_kia_connect_api-3.33.4.dist-info/METADATA,sha256=NEgtNiYgZKpYQdfQ8VWDLSy1qFoXt5CB4Np1UW2_1wY,7142
20
+ hyundai_kia_connect_api-3.33.4.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
21
+ hyundai_kia_connect_api-3.33.4.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
+ hyundai_kia_connect_api-3.33.4.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
+ hyundai_kia_connect_api-3.33.4.dist-info/RECORD,,