hyundai-kia-connect-api 3.32.15__py2.py3-none-any.whl → 3.33.0__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,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, token: Token, vehicle: Vehicle, use_email: bool
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
- email_parameter = ""
116
- if use_email is True:
117
- email_parameter = "&email=" + token.username
118
-
119
- url = (
120
- "https://nominatim.openstreetmap.org/reverse?lat="
121
- + str(vehicle.location_latitude)
122
- + "&lon="
123
- + str(vehicle.location_longitude)
124
- + "&format=json&addressdetails=1&zoom=18"
125
- + email_parameter
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
@@ -749,6 +749,7 @@ class HyundaiBlueLinkApiUSA(ApiImpl):
749
749
  model=entry["modelCode"],
750
750
  registration_date=entry["enrollmentDate"],
751
751
  timezone=self.data_timezone,
752
+ enabled=entry.get("enrollmentStatus") != "CANCELLED",
752
753
  generation=entry.get("vehicleGeneration", 2),
753
754
  )
754
755
  result.append(vehicle)
@@ -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, vehicle, self.geocode_api_use_email
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.")
@@ -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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.32.15
3
+ Version: 3.33.0
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
 
@@ -1,6 +1,6 @@
1
- hyundai_kia_connect_api/ApiImpl.py,sha256=sgUXOcQnBMTVylxOLeqnYOGnz9KqLqRClRpE12u6ZS4,7806
1
+ hyundai_kia_connect_api/ApiImpl.py,sha256=PuK3dID01qTGB6aGtQY4uf1hF-t4d03wUzG_gUFn_1g,8353
2
2
  hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
3
- hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=l4IAY1DqUh01WzPgM8TDlYKR80FEvqLkYqrfNtyT9Yw,36918
3
+ hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
4
4
  hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=tslh0gzvPBwYJmcWlf9B0l7PyYZdy2e7GqpRkl8_Svk,48471
5
5
  hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=XBya0yHZ2MC3TBVQLSc6N-SzmGt_s3l4nGVyNgmjl9Q,32514
6
6
  hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
@@ -8,16 +8,16 @@ hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=TxgO2dfLjKSKfSkRMoTL_fbmzRFRPb8oJ9
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
11
- hyundai_kia_connect_api/VehicleManager.py,sha256=SfGuCT0foCJqUNNLXs_9lRR5XGQ7xd-fodTIs3JEl0o,11167
11
+ hyundai_kia_connect_api/VehicleManager.py,sha256=k2MZR6nuPPrH1G9cLrukjYyDAar-M39qdNcQtl1ntPI,11512
12
12
  hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
13
13
  hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn-rYEjI,19730
14
- hyundai_kia_connect_api/const.py,sha256=scBlhrMims0W6_pESVVdQz2uUxczg2cf2qDQ7avbhVo,2174
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.32.15.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
- hyundai_kia_connect_api-3.32.15.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
- hyundai_kia_connect_api-3.32.15.dist-info/METADATA,sha256=E5HTqYKSAUTNn9z96HFGuVNVhoHtq9JM8IhO7J-OzmE,6894
20
- hyundai_kia_connect_api-3.32.15.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
21
- hyundai_kia_connect_api-3.32.15.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
- hyundai_kia_connect_api-3.32.15.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
- hyundai_kia_connect_api-3.32.15.dist-info/RECORD,,
17
+ hyundai_kia_connect_api-3.33.0.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
+ hyundai_kia_connect_api-3.33.0.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
+ hyundai_kia_connect_api-3.33.0.dist-info/METADATA,sha256=XVjyHKnqYRRtOs_DdZDcMRdcNAIqAMmQRp8QmIongwU,7142
20
+ hyundai_kia_connect_api-3.33.0.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
21
+ hyundai_kia_connect_api-3.33.0.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
+ hyundai_kia_connect_api-3.33.0.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
+ hyundai_kia_connect_api-3.33.0.dist-info/RECORD,,