hyundai-kia-connect-api 3.27.0__py2.py3-none-any.whl → 3.29.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.
@@ -62,8 +62,8 @@ class cipherAdapter(HTTPAdapter):
62
62
  return super().proxy_manager_for(*args, **kwargs)
63
63
 
64
64
 
65
- class HyundaiBlueLinkAPIUSA(ApiImpl):
66
- """HyundaiBlueLinkAPIUSA"""
65
+ class HyundaiBlueLinkApiUSA(ApiImpl):
66
+ """HyundaiBlueLinkApiUSA"""
67
67
 
68
68
  # initialize with a timestamp which will allow the first fetch to occur
69
69
  last_loc_timestamp = dt.datetime.now(pytz.utc) - dt.timedelta(hours=3)
@@ -386,8 +386,8 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
386
386
  vehicle.ev_battery_is_plugged_in = get_child_value(
387
387
  state, "vehicleStatus.evStatus.batteryPlugin"
388
388
  )
389
- vehicle.ev_charging_current = get_child_value(
390
- state, "vehicleStatus.evStatus.batteryStndChrgPower"
389
+ vehicle.ev_charging_power = get_child_value(
390
+ state, "vehicleStatus.evStatus.batteryPower.batteryStndChrgPower"
391
391
  )
392
392
  ChargeDict = get_child_value(
393
393
  state, "vehicleStatus.evStatus.reservChargeInfos.targetSOClist"
@@ -520,6 +520,11 @@ class KiaUvoApiEU(ApiImplType1):
520
520
  vehicle.ev_charge_port_door_is_open = True
521
521
  elif ev_charge_port_door_is_open == 2:
522
522
  vehicle.ev_charge_port_door_is_open = False
523
+
524
+ vehicle.ev_charging_power = get_child_value(
525
+ state, "vehicleStatus.evStatus.batteryPower.batteryStndChrgPower"
526
+ )
527
+
523
528
  if (
524
529
  get_child_value(
525
530
  state,
@@ -106,8 +106,8 @@ def request_with_logging(func):
106
106
  return request_with_logging_wrapper
107
107
 
108
108
 
109
- class KiaUvoAPIUSA(ApiImpl):
110
- """KiaUvoAPIUSA"""
109
+ class KiaUvoApiUSA(ApiImpl):
110
+ """KiaUvoApiUSA"""
111
111
 
112
112
  def __init__(self, region: int, brand: int, language) -> None:
113
113
  self.LANGUAGE: str = language
@@ -156,11 +156,12 @@ class Vehicle:
156
156
  # EV fields (EV/PHEV)
157
157
 
158
158
  ev_charge_port_door_is_open: typing.Union[bool, None] = None
159
+ ev_charging_power: typing.Union[float, None] = None # Charging power in kW
159
160
 
160
161
  ev_charge_limits_dc: typing.Union[int, None] = None
161
162
  ev_charge_limits_ac: typing.Union[int, None] = None
162
163
  ev_charging_current: typing.Union[int, None] = (
163
- None # Only supported in some regions
164
+ None # Europe feature only, ac charging current limit
164
165
  )
165
166
  ev_v2l_discharge_limit: typing.Union[int, None] = None
166
167
 
@@ -424,7 +425,7 @@ class Vehicle:
424
425
  def air_temperature(self, value):
425
426
  self._air_temperature_value = value[0]
426
427
  self._air_temperature_unit = value[1]
427
- self._air_temperature = value[0]
428
+ self._air_temperature = value[0] if value[0] != "OFF" else None
428
429
 
429
430
  @property
430
431
  def ev_driving_range(self):
@@ -14,8 +14,8 @@ from .ApiImpl import (
14
14
  WindowRequestOptions,
15
15
  ScheduleChargingClimateRequestOptions,
16
16
  )
17
- from .HyundaiBlueLinkAPIUSA import HyundaiBlueLinkAPIUSA
18
- from .KiaUvoAPIUSA import KiaUvoAPIUSA
17
+ from .HyundaiBlueLinkApiUSA import HyundaiBlueLinkApiUSA
18
+ from .KiaUvoApiUSA import KiaUvoApiUSA
19
19
  from .KiaUvoApiCA import KiaUvoApiCA
20
20
  from .KiaUvoApiEU import KiaUvoApiEU
21
21
  from .KiaUvoApiCN import KiaUvoApiCN
@@ -284,9 +284,9 @@ class VehicleManager:
284
284
  elif REGIONS[region] == REGION_USA and (
285
285
  BRANDS[brand] == BRAND_HYUNDAI or BRANDS[brand] == BRAND_GENESIS
286
286
  ):
287
- return HyundaiBlueLinkAPIUSA(region, brand, language)
287
+ return HyundaiBlueLinkApiUSA(region, brand, language)
288
288
  elif REGIONS[region] == REGION_USA and BRANDS[brand] == BRAND_KIA:
289
- return KiaUvoAPIUSA(region, brand, language)
289
+ return KiaUvoApiUSA(region, brand, language)
290
290
  elif REGIONS[region] == REGION_CHINA:
291
291
  return KiaUvoApiCN(region, brand, language)
292
292
  elif REGIONS[region] == REGION_AUSTRALIA:
@@ -0,0 +1,457 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Connects to the Bluelink API and query the vehicle."""
4
+
5
+ import argparse
6
+ import datetime
7
+ import json
8
+ import logging
9
+ import os
10
+ import sys
11
+ import textwrap
12
+
13
+ import hyundai_kia_connect_api
14
+ from hyundai_kia_connect_api import const
15
+
16
+
17
+ def print_vehicle(vehicle):
18
+ print("Identification")
19
+ print(" id:", vehicle.id)
20
+ print(" name:", vehicle.name)
21
+ print(" model:", vehicle.model)
22
+ print(" registration_date:", vehicle.registration_date)
23
+ print(" year:", vehicle.year)
24
+ print(" VIN:", vehicle.VIN)
25
+ print(" key:", vehicle.key)
26
+ print("General")
27
+ print(" engine_type:", vehicle.engine_type)
28
+ print(" ccu_ccs2_protocol_support:", vehicle.ccu_ccs2_protocol_support)
29
+ print(
30
+ " total_driving_range:",
31
+ vehicle.total_driving_range,
32
+ vehicle.total_driving_range_unit,
33
+ )
34
+ print(" odometer:", vehicle.odometer, vehicle.odometer_unit)
35
+ print(" geocode:", vehicle.geocode)
36
+ print(" car_battery_percentage:", vehicle.car_battery_percentage)
37
+ print(" engine_is_running:", vehicle.engine_is_running)
38
+ print(" last_updated_at:", vehicle.last_updated_at)
39
+ print(" timezone:", vehicle.timezone)
40
+ print(" dtc_count:", vehicle.dtc_count)
41
+ print(" dtc_descriptions:", vehicle.dtc_descriptions)
42
+ print(" smart_key_battery_warning_is_on:", vehicle.smart_key_battery_warning_is_on)
43
+ print(" washer_fluid_warning_is_on:", vehicle.washer_fluid_warning_is_on)
44
+ print(" brake_fluid_warning_is_on:", vehicle.brake_fluid_warning_is_on)
45
+ print("Climate")
46
+ print(" air_temperature:", vehicle.air_temperature, vehicle._air_temperature_unit)
47
+ print(" air_control_is_on:", vehicle.air_control_is_on)
48
+ print(" defrost_is_on:", vehicle.defrost_is_on)
49
+ print(" steering_wheel_heater_is_on:", vehicle.steering_wheel_heater_is_on)
50
+ print(" back_window_heater_is_on:", vehicle.back_window_heater_is_on)
51
+ print(" side_mirror_heater_is_on:", vehicle.side_mirror_heater_is_on)
52
+ print(" front_left_seat_status:", vehicle.front_left_seat_status)
53
+ print(" front_right_seat_status:", vehicle.front_right_seat_status)
54
+ print(" rear_left_seat_status:", vehicle.rear_left_seat_status)
55
+ print(" rear_right_seat_status:", vehicle.rear_right_seat_status)
56
+ print("Doors")
57
+ print(" is_locked:", vehicle.is_locked)
58
+ print(" front_left_door_is_open:", vehicle.front_left_door_is_open)
59
+ print(" front_right_door_is_open:", vehicle.front_right_door_is_open)
60
+ print(" back_left_door_is_open:", vehicle.back_left_door_is_open)
61
+ print(" back_right_door_is_open:", vehicle.back_right_door_is_open)
62
+ print(" trunk_is_open:", vehicle.trunk_is_open)
63
+ print(" hood_is_open:", vehicle.hood_is_open)
64
+ print("Windows")
65
+ print(" front_left_window_is_open:", vehicle.front_left_window_is_open)
66
+ print(" front_right_window_is_open:", vehicle.front_right_window_is_open)
67
+ print(" back_left_window_is_open:", vehicle.back_left_window_is_open)
68
+ print(" back_right_window_is_open:", vehicle.back_right_window_is_open)
69
+ print("Tire Pressure")
70
+ print(" tire_pressure_all_warning_is_on:", vehicle.tire_pressure_all_warning_is_on)
71
+ print(
72
+ " tire_pressure_rear_left_warning_is_on:",
73
+ vehicle.tire_pressure_rear_left_warning_is_on,
74
+ )
75
+ print(
76
+ " tire_pressure_front_left_warning_is_on:",
77
+ vehicle.tire_pressure_front_left_warning_is_on,
78
+ )
79
+ print(
80
+ " tire_pressure_front_right_warning_is_on:",
81
+ vehicle.tire_pressure_front_right_warning_is_on,
82
+ )
83
+ print(
84
+ " tire_pressure_rear_right_warning_is_on:",
85
+ vehicle.tire_pressure_rear_right_warning_is_on,
86
+ )
87
+ print("Service")
88
+ print(
89
+ " next_service_distance:",
90
+ vehicle.next_service_distance,
91
+ vehicle._next_service_distance_unit,
92
+ )
93
+ print(
94
+ " last_service_distance:",
95
+ vehicle.last_service_distance,
96
+ vehicle._last_service_distance_unit,
97
+ )
98
+ print("Location")
99
+ print(" location:", vehicle.location)
100
+ print(" location_last_updated_at:", vehicle.location_last_updated_at)
101
+ print("EV/PHEV")
102
+ print(" charge_port_door_is_open:", vehicle.ev_charge_port_door_is_open)
103
+ print(" charging_power:", vehicle.ev_charging_power)
104
+ print(" charge_limits_dc:", vehicle.ev_charge_limits_dc)
105
+ print(" charge_limits_ac:", vehicle.ev_charge_limits_ac)
106
+ print(" charging_current:", vehicle.ev_charging_current)
107
+ print(" v2l_discharge_limit:", vehicle.ev_v2l_discharge_limit)
108
+ print(" total_power_consumed:", vehicle.total_power_consumed, "Wh")
109
+ print(" total_power_regenerated:", vehicle.total_power_regenerated, "Wh")
110
+ print(" power_consumption_30d:", vehicle.power_consumption_30d, "Wh")
111
+ print(" battery_percentage:", vehicle.ev_battery_percentage)
112
+ print(" battery_soh_percentage:", vehicle.ev_battery_soh_percentage)
113
+ print(" battery_remain:", vehicle.ev_battery_remain)
114
+ print(" battery_capacity:", vehicle.ev_battery_capacity)
115
+ print(" battery_is_charging:", vehicle.ev_battery_is_charging)
116
+ print(" battery_is_plugged_in:", vehicle.ev_battery_is_plugged_in)
117
+ print(" driving_range:", vehicle.ev_driving_range, vehicle._ev_driving_range_unit)
118
+ print(
119
+ " estimated_current_charge_duration:",
120
+ vehicle.ev_estimated_current_charge_duration,
121
+ vehicle._ev_estimated_current_charge_duration_unit,
122
+ )
123
+ print(
124
+ " estimated_fast_charge_duration:",
125
+ vehicle.ev_estimated_fast_charge_duration,
126
+ vehicle._ev_estimated_fast_charge_duration_unit,
127
+ )
128
+ print(
129
+ " estimated_portable_charge_duration:",
130
+ vehicle.ev_estimated_portable_charge_duration,
131
+ vehicle._ev_estimated_portable_charge_duration_unit,
132
+ )
133
+ print(
134
+ " estimated_station_charge_duration:",
135
+ vehicle.ev_estimated_station_charge_duration,
136
+ vehicle._ev_estimated_station_charge_duration_unit,
137
+ )
138
+ print(
139
+ " target_range_charge_AC:",
140
+ vehicle.ev_target_range_charge_AC,
141
+ vehicle._ev_target_range_charge_AC_unit,
142
+ )
143
+ print(
144
+ " target_range_charge_DC:",
145
+ vehicle.ev_target_range_charge_DC,
146
+ vehicle._ev_target_range_charge_DC_unit,
147
+ )
148
+
149
+ print(" first_departure_enabled:", vehicle.ev_first_departure_enabled)
150
+ print(
151
+ " first_departure_climate_temperature:",
152
+ vehicle.ev_first_departure_climate_temperature,
153
+ vehicle._ev_first_departure_climate_temperature_unit,
154
+ )
155
+ print(" first_departure_days:", vehicle.ev_first_departure_days)
156
+ print(" first_departure_time:", vehicle.ev_first_departure_time)
157
+ print(
158
+ " first_departure_climate_enabled:", vehicle.ev_first_departure_climate_enabled
159
+ )
160
+ print(
161
+ " first_departure_climate_defrost:", vehicle.ev_first_departure_climate_defrost
162
+ )
163
+ print(" second_departure_enabled:", vehicle.ev_second_departure_enabled)
164
+ print(
165
+ " second_departure_climate_temperature:",
166
+ vehicle.ev_second_departure_climate_temperature,
167
+ vehicle._ev_second_departure_climate_temperature_unit,
168
+ )
169
+ print(" second_departure_days:", vehicle.ev_second_departure_days)
170
+ print(" second_departure_time:", vehicle.ev_second_departure_time)
171
+ print(
172
+ " second_departure_climate_enabled:",
173
+ vehicle.ev_second_departure_climate_enabled,
174
+ )
175
+ print(
176
+ " second_departure_climate_defrost:",
177
+ vehicle.ev_second_departure_climate_defrost,
178
+ )
179
+ print(" off_peak_start_time:", vehicle.ev_off_peak_start_time)
180
+ print(" off_peak_end_time:", vehicle.ev_off_peak_end_time)
181
+ print(" off_peak_charge_only_enabled:", vehicle.ev_off_peak_charge_only_enabled)
182
+ print(" schedule_charge_enabled:", vehicle.ev_schedule_charge_enabled)
183
+ print("PHEV/HEV/IC")
184
+ print(
185
+ " fuel_driving_range:",
186
+ vehicle.fuel_driving_range,
187
+ vehicle._fuel_driving_range_unit,
188
+ )
189
+ print(" fuel_level:", vehicle.fuel_level)
190
+ print(" fuel_level_is_low:", vehicle.fuel_level_is_low)
191
+ print("Trips")
192
+ print(" daily_stats:", vehicle.daily_stats)
193
+ print(" month_trip_info:", vehicle.month_trip_info)
194
+ print(" day_trip_info:", vehicle.day_trip_info)
195
+ print("Debug")
196
+ print(textwrap.indent(json.dumps(vehicle.data, indent=2, sort_keys=True), " "))
197
+
198
+
199
+ def vehicle_to_dict(vehicle):
200
+ return {
201
+ "identification": {
202
+ "id": vehicle.id,
203
+ "name": vehicle.name,
204
+ "model": vehicle.model,
205
+ "registration_date": vehicle.registration_date,
206
+ "year": vehicle.year,
207
+ "VIN": vehicle.VIN,
208
+ "key": vehicle.key,
209
+ },
210
+ "general": {
211
+ "engine_type": str(vehicle.engine_type),
212
+ "ccu_ccs2_protocol_support": vehicle.ccu_ccs2_protocol_support,
213
+ "total_driving_range": [
214
+ vehicle.total_driving_range,
215
+ vehicle.total_driving_range_unit,
216
+ ],
217
+ "odometer": [vehicle.odometer, vehicle.odometer_unit],
218
+ "geocode": vehicle.geocode,
219
+ "car_battery_percentage": vehicle.car_battery_percentage,
220
+ "engine_is_running": vehicle.engine_is_running,
221
+ "last_updated_at": vehicle.last_updated_at,
222
+ "timezone": vehicle.timezone,
223
+ "dtc_count": vehicle.dtc_count,
224
+ "dtc_descriptions": vehicle.dtc_descriptions,
225
+ "smart_key_battery_warning_is_on": vehicle.smart_key_battery_warning_is_on,
226
+ "washer_fluid_warning_is_on": vehicle.washer_fluid_warning_is_on,
227
+ "brake_fluid_warning_is_on": vehicle.brake_fluid_warning_is_on,
228
+ },
229
+ "climate": {
230
+ "air_temperature": [
231
+ vehicle.air_temperature,
232
+ vehicle._air_temperature_unit,
233
+ ],
234
+ "air_control_is_on": vehicle.air_control_is_on,
235
+ "defrost_is_on": vehicle.defrost_is_on,
236
+ "steering_wheel_heater_is_on": vehicle.steering_wheel_heater_is_on,
237
+ "back_window_heater_is_on": vehicle.back_window_heater_is_on,
238
+ "side_mirror_heater_is_on": vehicle.side_mirror_heater_is_on,
239
+ "front_left_seat_status": vehicle.front_left_seat_status,
240
+ "front_right_seat_status": vehicle.front_right_seat_status,
241
+ "rear_left_seat_status": vehicle.rear_left_seat_status,
242
+ "rear_right_seat_status": vehicle.rear_right_seat_status,
243
+ },
244
+ "doors": {
245
+ "is_locked": vehicle.is_locked,
246
+ "front_left_door_is_open": vehicle.front_left_door_is_open,
247
+ "front_right_door_is_open": vehicle.front_right_door_is_open,
248
+ "back_left_door_is_open": vehicle.back_left_door_is_open,
249
+ "back_right_door_is_open": vehicle.back_right_door_is_open,
250
+ "trunk_is_open": vehicle.trunk_is_open,
251
+ "hood_is_open": vehicle.hood_is_open,
252
+ },
253
+ "windows": {
254
+ "front_left_window_is_open": vehicle.front_left_window_is_open,
255
+ "front_right_window_is_open": vehicle.front_right_window_is_open,
256
+ "back_left_window_is_open": vehicle.back_left_window_is_open,
257
+ "back_right_window_is_open": vehicle.back_right_window_is_open,
258
+ },
259
+ "tires": {
260
+ "tire_pressure_all_warning_is_on": vehicle.tire_pressure_all_warning_is_on,
261
+ "tire_pressure_rear_left_warning_is_on": vehicle.tire_pressure_rear_left_warning_is_on,
262
+ "tire_pressure_front_left_warning_is_on": vehicle.tire_pressure_front_left_warning_is_on,
263
+ "tire_pressure_front_right_warning_is_on": vehicle.tire_pressure_front_right_warning_is_on,
264
+ "tire_pressure_rear_right_warning_is_on": vehicle.tire_pressure_rear_right_warning_is_on,
265
+ },
266
+ "service": {
267
+ "next_service_distance": [
268
+ vehicle.next_service_distance,
269
+ vehicle._next_service_distance_unit,
270
+ ],
271
+ "last_service_distance": [
272
+ vehicle.last_service_distance,
273
+ vehicle._last_service_distance_unit,
274
+ ],
275
+ },
276
+ "location": {
277
+ "location": vehicle.location,
278
+ "location_last_updated_at": vehicle.location_last_updated_at,
279
+ },
280
+ "electric": {
281
+ "charge_port_door_is_open": vehicle.ev_charge_port_door_is_open,
282
+ "charging_power": vehicle.ev_charging_power,
283
+ "charge_limits_dc": vehicle.ev_charge_limits_dc,
284
+ "charge_limits_ac": vehicle.ev_charge_limits_ac,
285
+ "charging_current": vehicle.ev_charging_current,
286
+ "v2l_discharge_limit": vehicle.ev_v2l_discharge_limit,
287
+ "total_power_consumed": [vehicle.total_power_consumed, "Wh"],
288
+ "total_power_regenerated": [vehicle.total_power_regenerated, "Wh"],
289
+ "power_consumption_30d": [vehicle.power_consumption_30d, "Wh"],
290
+ "battery_percentage": vehicle.ev_battery_percentage,
291
+ "battery_soh_percentage": vehicle.ev_battery_soh_percentage,
292
+ "battery_remain": vehicle.ev_battery_remain,
293
+ "battery_capacity": vehicle.ev_battery_capacity,
294
+ "battery_is_charging": vehicle.ev_battery_is_charging,
295
+ "battery_is_plugged_in": vehicle.ev_battery_is_plugged_in,
296
+ "driving_range": [
297
+ vehicle.ev_driving_range,
298
+ vehicle._ev_driving_range_unit,
299
+ ],
300
+ "estimated_current_charge_duration": [
301
+ vehicle.ev_estimated_current_charge_duration,
302
+ vehicle._ev_estimated_current_charge_duration_unit,
303
+ ],
304
+ "estimated_fast_charge_duration": [
305
+ vehicle.ev_estimated_fast_charge_duration,
306
+ vehicle._ev_estimated_fast_charge_duration_unit,
307
+ ],
308
+ "estimated_portable_charge_duration": [
309
+ vehicle.ev_estimated_portable_charge_duration,
310
+ vehicle._ev_estimated_portable_charge_duration_unit,
311
+ ],
312
+ "estimated_station_charge_duration": [
313
+ vehicle.ev_estimated_station_charge_duration,
314
+ vehicle._ev_estimated_station_charge_duration_unit,
315
+ ],
316
+ "target_range_charge_AC": [
317
+ vehicle.ev_target_range_charge_AC,
318
+ vehicle._ev_target_range_charge_AC_unit,
319
+ ],
320
+ "target_range_charge_DC": [
321
+ vehicle.ev_target_range_charge_DC,
322
+ vehicle._ev_target_range_charge_DC_unit,
323
+ ],
324
+ "first_departure_enabled": vehicle.ev_first_departure_enabled,
325
+ "first_departure_climate_temperature": [
326
+ vehicle.ev_first_departure_climate_temperature,
327
+ vehicle._ev_first_departure_climate_temperature_unit,
328
+ ],
329
+ "first_departure_days": vehicle.ev_first_departure_days,
330
+ "first_departure_time": vehicle.ev_first_departure_time,
331
+ "first_departure_climate_enabled": vehicle.ev_first_departure_climate_enabled,
332
+ "first_departure_climate_defrost": vehicle.ev_first_departure_climate_defrost,
333
+ "second_departure_enabled": vehicle.ev_second_departure_enabled,
334
+ "second_departure_climate_temperature": [
335
+ vehicle.ev_second_departure_climate_temperature,
336
+ vehicle._ev_second_departure_climate_temperature_unit,
337
+ ],
338
+ "second_departure_days": vehicle.ev_second_departure_days,
339
+ "second_departure_time": vehicle.ev_second_departure_time,
340
+ "second_departure_climate_enabled": vehicle.ev_second_departure_climate_enabled,
341
+ "second_departure_climate_defrost": vehicle.ev_second_departure_climate_defrost,
342
+ "off_peak_start_time": vehicle.ev_off_peak_start_time,
343
+ "off_peak_end_time": vehicle.ev_off_peak_end_time,
344
+ "off_peak_charge_only_enabled": vehicle.ev_off_peak_charge_only_enabled,
345
+ "schedule_charge_enabled": vehicle.ev_schedule_charge_enabled,
346
+ },
347
+ "ic": {
348
+ "fuel_driving_range": [
349
+ vehicle.fuel_driving_range,
350
+ vehicle._fuel_driving_range_unit,
351
+ ],
352
+ "fuel_level": vehicle.fuel_level,
353
+ "fuel_level_is_low": vehicle.fuel_level_is_low,
354
+ },
355
+ "trips": {
356
+ "daily_stats": vehicle.daily_stats,
357
+ "month_trip_info": vehicle.month_trip_info,
358
+ "day_trip_info": vehicle.day_trip_info,
359
+ },
360
+ "debug": vehicle.data,
361
+ }
362
+
363
+
364
+ class DateTimeEncoder(json.JSONEncoder):
365
+ def default(self, obj):
366
+ if isinstance(obj, (datetime.date, datetime.datetime)):
367
+ return obj.isoformat()
368
+
369
+
370
+ def cmd_info(vm, args):
371
+ for vehicle_id, vehicle in vm.vehicles.items():
372
+ print_vehicle(vehicle)
373
+ if args.json:
374
+ data = {id: vehicle_to_dict(v) for id, v in vm.vehicles.items()}
375
+ json.dump(data, args.json, separators=(",", ":"), cls=DateTimeEncoder)
376
+ return 0
377
+
378
+
379
+ def main():
380
+ default_username = os.environ.get("BLUELINK_USERNAME", "")
381
+ default_password = os.environ.get("BLUELINK_PASSWORD", "")
382
+ default_pin = None
383
+ if os.environ.get("BLUELINK_PIN", ""):
384
+ try:
385
+ default_pin = int(os.environ["BLUELINK_PIN"])
386
+ except ValueError:
387
+ print("Invalid BLUELINK_PIN environment variable", file=sys.stderr)
388
+ return 1
389
+
390
+ parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
391
+ parser.add_argument(
392
+ "--region",
393
+ default=os.environ.get("BLUELINK_REGION", const.REGION_CANADA),
394
+ choices=sorted(const.REGIONS.values()),
395
+ help="Car's region, use env var BLUELINK_REGION",
396
+ )
397
+ parser.add_argument(
398
+ "--brand",
399
+ default=os.environ.get("BLUELINK_BRAND", const.BRAND_HYUNDAI),
400
+ choices=sorted(const.BRANDS.values()),
401
+ help="Car's brand, use env var BLUELINK_BRAND",
402
+ )
403
+ parser.add_argument(
404
+ "--username",
405
+ default=default_username,
406
+ help="Bluelink account username, use env var BLUELINK_USERNAME",
407
+ required=not default_username,
408
+ )
409
+ parser.add_argument(
410
+ "--password",
411
+ default=default_password,
412
+ help="Bluelink account password, use env var BLUELINK_PASSWORD",
413
+ required=not default_password,
414
+ )
415
+ parser.add_argument(
416
+ "--pin",
417
+ type=int,
418
+ default=default_pin,
419
+ help="Bluelink account pin, use env var BLUELINK_PIN",
420
+ required=not default_pin,
421
+ )
422
+ parser.add_argument("-v", "--verbose", action=argparse.BooleanOptionalAction)
423
+ subparsers = parser.add_subparsers(help="Commands", required=True)
424
+ parser_info = subparsers.add_parser(
425
+ "info", help="Prints infos about the cars found"
426
+ )
427
+ parser_info.set_defaults(func=cmd_info)
428
+ parser_info.add_argument(
429
+ "--json",
430
+ type=argparse.FileType("w", encoding="UTF-8"),
431
+ help="Save data to file as JSON",
432
+ )
433
+
434
+ args = parser.parse_args()
435
+ logging.basicConfig(level=logging.DEBUG if args.verbose else logging.ERROR)
436
+
437
+ # Reverse lookup.
438
+ region = [k for k, v in const.REGIONS.items() if v == args.region][0]
439
+ brand = [k for k, v in const.BRANDS.items() if v == args.brand][0]
440
+
441
+ vm = hyundai_kia_connect_api.VehicleManager(
442
+ region=region,
443
+ brand=brand,
444
+ username=args.username,
445
+ password=args.password,
446
+ pin=args.pin,
447
+ geocode_api_enable=True,
448
+ geocode_api_use_email=True,
449
+ )
450
+ # TODO: Cache token.
451
+ vm.check_and_refresh_token()
452
+ vm.update_all_vehicles_with_cached_state()
453
+ return args.func(vm, args)
454
+
455
+
456
+ if __name__ == "__main__":
457
+ sys.exit(main())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.27.0
3
+ Version: 3.29.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
@@ -29,10 +29,16 @@ I no longer have a Kia or Hyundai so don't maintain this like I used to. Others
29
29
  Introduction
30
30
  ============
31
31
 
32
- This is a Kia UVO, Hyundai Bluelink, Genesis Connect(Canada Only) written in python. It is primary consumed by home assistant. If you are looking for a home assistant Kia / Hyundai implementation please look here: https://github.com/Hyundai-Kia-Connect/kia_uvo. Much of this base code came from reading bluelinky (https://github.com/Hacksore/bluelinky) and contributions to the kia_uvo home assistant project.
32
+ This is a Kia UVO, Hyundai Bluelink, Genesis Connect(Canada Only) written in python. It is primary consumed by home assistant. If you are looking for a home assistant Kia / Hyundai implementation please look here: https://github.com/Hyundai-Kia-Connect/kia_uvo. Much of this base code came from reading `bluelinky <https://github.com/Hacksore/bluelinky>`_ and contributions to the kia_uvo home assistant project.
33
33
 
34
- Usage
35
- =====
34
+ Chat on discord:: |Discord|
35
+
36
+ .. |Discord| image:: https://img.shields.io/discord/652755205041029120
37
+ :target: https://discord.gg/HwnG8sY
38
+ :alt: Discord
39
+
40
+ API Usage
41
+ =========
36
42
 
37
43
  This package is designed to simplify the complexity of using multiple regions. It attempts to standardize the usage regardless of what brand or region the car is in. That isn't always possible though, in particular some features differ from one to the next.
38
44
 
@@ -44,7 +50,7 @@ Python 3.10 or newer is required to use this package. Vehicle manager is the key
44
50
  password: str
45
51
  pin: str (required for CA, and potentially USA, otherwise pass a blank string)
46
52
 
47
- Key values for the int exist in the constant(https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/const.py) file as::
53
+ 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::
48
54
 
49
55
  REGIONS = {1: REGION_EUROPE, 2: REGION_CANADA, 3: REGION_USA, 4: REGION_CHINA, 5: REGION_AUSTRALIA}
50
56
  BRANDS = {1: BRAND_KIA, 2: BRAND_HYUNDAI, 3: BRAND_GENESIS}
@@ -129,3 +135,17 @@ Example of getting trip info of the current month and day (vm is VehicleManager
129
135
  if vehicle.day_trip_info is not None:
130
136
  for trip in reversed(vehicle.day_trip_info.trip_list): # show oldest first
131
137
  print(f"{day.yyyymmdd},{trip.hhmmss},{trip.drive_time},{trip.idle_time},{trip.distance},{trip.avg_speed},{trip.max_speed}")
138
+
139
+
140
+ CLI Usage
141
+ =========
142
+
143
+ A tool `bluelink` is provided that enable querying the vehicles and save the
144
+ state to a JSON file. Example usage:
145
+
146
+ ::
147
+
148
+ bluelink --region Canada --brand Hyundai --username FOO --password BAR --pin 1234 info --json infos.json
149
+
150
+ Environment variables BLUELINK_XXX can be used to provide a default value for
151
+ the corresponding --xxx argument.
@@ -0,0 +1,23 @@
1
+ hyundai_kia_connect_api/ApiImpl.py,sha256=9DoAtk8-pE0WaLzRTM7uydkUoxS_Almcooeonp7vTQE,7538
2
+ hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
3
+ hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=Tx-L4ZWiPhq-uHcjWSUzjLEsfunV6nzyzqQpjPTYuIo,36831
4
+ hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=tslh0gzvPBwYJmcWlf9B0l7PyYZdy2e7GqpRkl8_Svk,48471
5
+ hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=B3Lks_ONr3l01QLl-GQBPdktXj9PZWKuQKRLYmJ7kP4,30763
6
+ hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
7
+ hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=wNHMuyANzunMzp6DtjJmA1k4DbkXcHvebA-bS107ueA,70416
8
+ hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=J7bDKgPqXnwMcG8aaw8gfwKs8XO-D0mTxC41vOpDlgw,31338
9
+ hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
10
+ hyundai_kia_connect_api/Vehicle.py,sha256=raCMzJsLuJnVHlFJ16VKdKat55L0uivbbcZRDCGWTxI,18793
11
+ hyundai_kia_connect_api/VehicleManager.py,sha256=X_m8H9Jsg-P1x0QmD5wZOVLMppZ4I__ZMi7rOLSTRuE,10940
12
+ hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
13
+ hyundai_kia_connect_api/bluelink.py,sha256=sBU7hlElie21GU4Ma-i4a5vdztGc2jtmlVBbbgUqmTE,19720
14
+ hyundai_kia_connect_api/const.py,sha256=HE0_1_be4ERB73vsekWxv6TDWd8cvAgY1oPZojUrcwM,2096
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.29.1.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
18
+ hyundai_kia_connect_api-3.29.1.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
19
+ hyundai_kia_connect_api-3.29.1.dist-info/METADATA,sha256=5ivYJSNh7jK42y37I5LzQSDdjL4Zhx2HG-Qc1DKXxDE,6678
20
+ hyundai_kia_connect_api-3.29.1.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
21
+ hyundai_kia_connect_api-3.29.1.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
22
+ hyundai_kia_connect_api-3.29.1.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
23
+ hyundai_kia_connect_api-3.29.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bluelink = hyundai_kia_connect_api.bluelink:main
@@ -1,21 +0,0 @@
1
- hyundai_kia_connect_api/ApiImpl.py,sha256=9DoAtk8-pE0WaLzRTM7uydkUoxS_Almcooeonp7vTQE,7538
2
- hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
3
- hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py,sha256=FqsU3R938nK-jVDkajs_niutXW_eoGNCLdsLhdNbx8c,36820
4
- hyundai_kia_connect_api/KiaUvoAPIUSA.py,sha256=LbEh7EM19kpvhwPSMpEYIHVNUSOJsuvNjcXJzyc_P8A,31338
5
- hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=tslh0gzvPBwYJmcWlf9B0l7PyYZdy2e7GqpRkl8_Svk,48471
6
- hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=B3Lks_ONr3l01QLl-GQBPdktXj9PZWKuQKRLYmJ7kP4,30763
7
- hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
8
- hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=9KFtTYfBi7fyWABhFCVcKhqV6pWD7p-Wg9lvdfJso4E,70273
9
- hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
10
- hyundai_kia_connect_api/Vehicle.py,sha256=rJOob5q79hxAXx3IByPYkS0gS86NR5oQG8P4oW6LWQI,18666
11
- hyundai_kia_connect_api/VehicleManager.py,sha256=BfDdfLVSw04FvCv_sQweqOg_kPO6xD884XwAuPGKmTY,10940
12
- hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
13
- hyundai_kia_connect_api/const.py,sha256=HE0_1_be4ERB73vsekWxv6TDWd8cvAgY1oPZojUrcwM,2096
14
- hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
15
- hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
16
- hyundai_kia_connect_api-3.27.0.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
17
- hyundai_kia_connect_api-3.27.0.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
18
- hyundai_kia_connect_api-3.27.0.dist-info/METADATA,sha256=b8GAEqB4qSC-K3WLRl5FtWbN4Tyze_p3CtUKWXJgY-Q,6142
19
- hyundai_kia_connect_api-3.27.0.dist-info/WHEEL,sha256=OpXWERl2xLPRHTvd2ZXo_iluPEQd8uSbYkJ53NAER_Y,109
20
- hyundai_kia_connect_api-3.27.0.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
21
- hyundai_kia_connect_api-3.27.0.dist-info/RECORD,,