hyundai-kia-connect-api 3.33.2__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.
@@ -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
@@ -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.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
@@ -1,4 +1,4 @@
1
- hyundai_kia_connect_api/ApiImpl.py,sha256=PuK3dID01qTGB6aGtQY4uf1hF-t4d03wUzG_gUFn_1g,8353
1
+ hyundai_kia_connect_api/ApiImpl.py,sha256=PUZfRVb_I3uC6KaY2HK4TxBFfXyVqaXAgGO1GOAb1Hc,9344
2
2
  hyundai_kia_connect_api/ApiImplType1.py,sha256=6uSqZYWmFT08gH1OL1h7SJso3HvqH9GszSQzngQbWcc,16993
3
3
  hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
4
4
  hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=Ox-GXfu2h6dsAA1tgXRVDCYgMP5Hi9IHMXDBzmYzBxQ,45668
@@ -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.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,,