hyundai-kia-connect-api 3.22.9__tar.gz → 3.23.0__tar.gz

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.
Files changed (46) hide show
  1. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/PKG-INFO +1 -1
  2. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/ApiImplType1.py +1 -1
  3. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py +180 -1
  4. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/KiaUvoApiAU.py +1 -0
  5. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/KiaUvoApiCN.py +1 -0
  6. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/KiaUvoApiEU.py +1 -0
  7. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/Vehicle.py +1 -1
  8. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/PKG-INFO +1 -1
  9. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/setup.py +1 -1
  10. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/AUTHORS.rst +0 -0
  11. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/CONTRIBUTING.rst +0 -0
  12. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/HISTORY.rst +0 -0
  13. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/LICENSE +0 -0
  14. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/MANIFEST.in +0 -0
  15. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/README.rst +0 -0
  16. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/Makefile +0 -0
  17. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/authors.rst +0 -0
  18. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/conf.py +0 -0
  19. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/contributing.rst +0 -0
  20. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/history.rst +0 -0
  21. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/index.rst +0 -0
  22. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/installation.rst +0 -0
  23. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/make.bat +0 -0
  24. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/readme.rst +0 -0
  25. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/docs/usage.rst +0 -0
  26. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/ApiImpl.py +0 -0
  27. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/KiaUvoAPIUSA.py +0 -0
  28. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/KiaUvoApiCA.py +0 -0
  29. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/Token.py +0 -0
  30. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/VehicleManager.py +0 -0
  31. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/__init__.py +0 -0
  32. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/const.py +0 -0
  33. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/exceptions.py +0 -0
  34. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api/utils.py +0 -0
  35. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/SOURCES.txt +0 -0
  36. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/dependency_links.txt +0 -0
  37. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/not-zip-safe +0 -0
  38. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/requires.txt +0 -0
  39. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/hyundai_kia_connect_api.egg-info/top_level.txt +0 -0
  40. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/requirements.txt +0 -0
  41. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/setup.cfg +0 -0
  42. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/tests/__init__.py +0 -0
  43. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/tests/au_login_test.py +0 -0
  44. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/tests/ca_login_test.py +0 -0
  45. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/tests/eu_check_response_for_errors_test.py +0 -0
  46. {hyundai_kia_connect_api-3.22.9 → hyundai_kia_connect_api-3.23.0}/tests/eu_login_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.22.9
3
+ Version: 3.23.0
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/fuatakgun/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -1,4 +1,4 @@
1
- """ "ApiImplType1.py"""
1
+ """ApiImplType1.py"""
2
2
 
3
3
  import datetime as dt
4
4
  from typing import Optional
@@ -23,7 +23,14 @@ from .const import (
23
23
  from .utils import get_child_value, get_float, parse_datetime
24
24
  from .ApiImpl import ApiImpl, ClimateRequestOptions
25
25
  from .Token import Token
26
- from .Vehicle import DailyDrivingStats, Vehicle
26
+ from .Vehicle import (
27
+ DailyDrivingStats,
28
+ DayTripCounts,
29
+ DayTripInfo,
30
+ MonthTripInfo,
31
+ TripInfo,
32
+ Vehicle,
33
+ )
27
34
 
28
35
 
29
36
  CIPHERS = "DEFAULT@SECLEVEL=1"
@@ -449,6 +456,7 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
449
456
  )
450
457
  vehicle.air_control_is_on = get_child_value(state, "vehicleStatus.airCtrlOn")
451
458
 
459
+ # fill vehicle.daily_stats
452
460
  tripStats = []
453
461
  tripDetails = get_child_value(state, "evTripDetails.tripdetails") or {}
454
462
  for trip in tripDetails:
@@ -461,13 +469,184 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
461
469
  battery_care_consumption=get_child_value(trip, "batterycare"),
462
470
  regenerated_energy=get_child_value(trip, "regen"),
463
471
  distance=get_child_value(trip, "distance"),
472
+ distance_unit=vehicle.odometer_unit,
464
473
  )
465
474
  tripStats.append(processedTrip)
466
475
 
467
476
  vehicle.daily_stats = tripStats
468
477
 
478
+ # remember trips, store state
479
+ trips = []
480
+ for trip in tripDetails:
481
+ yyyymmdd_hhmmss = trip["startdate"] # remember full date
482
+ drive_time = get_child_value(trip["mileagetime"], "value")
483
+ processed_trip = TripInfo(
484
+ hhmmss=yyyymmdd_hhmmss,
485
+ drive_time=int(drive_time),
486
+ idle_time=int(get_child_value(trip["duration"], "value") - drive_time),
487
+ distance=int(trip["distance"]),
488
+ avg_speed=get_child_value(trip["avgspeed"], "value"),
489
+ max_speed=int(get_child_value(trip["maxspeed"], "value")),
490
+ )
491
+ trips.append(processed_trip)
492
+
493
+ _LOGGER.debug(f"_update_vehicle_properties filled_trips: {trips}")
494
+ if len(trips) > 0:
495
+ state["filled_trips"] = trips
496
+
469
497
  vehicle.data = state
470
498
 
499
+ def update_month_trip_info(
500
+ self,
501
+ token,
502
+ vehicle,
503
+ yyyymm_string,
504
+ ) -> None:
505
+ """
506
+ feature only available for some regions.
507
+ Updates the vehicle.month_trip_info for the specified month.
508
+
509
+ Default this information is None:
510
+
511
+ month_trip_info: MonthTripInfo = None
512
+ """
513
+ _LOGGER.debug(f"update_month_trip_info: {yyyymm_string}")
514
+ vehicle.month_trip_info = None
515
+
516
+ if vehicle.data is None or "filled_trips" not in vehicle.data:
517
+ _LOGGER.debug(f"filled_trips is empty: {vehicle.data}")
518
+ return # nothing to fill
519
+
520
+ trips = vehicle.data["filled_trips"]
521
+
522
+ month_trip_info: MonthTripInfo = None
523
+ month_trip_info_count = 0
524
+
525
+ for trip in trips:
526
+ date_str = trip.hhmmss
527
+ yyyymm = date_str[0:4] + date_str[5:7]
528
+ if yyyymm == yyyymm_string:
529
+ if month_trip_info_count == 0:
530
+ month_trip_info = MonthTripInfo(
531
+ yyyymm=yyyymm_string,
532
+ summary=TripInfo(
533
+ drive_time=trip.drive_time,
534
+ idle_time=trip.idle_time,
535
+ distance=trip.distance,
536
+ avg_speed=trip.avg_speed,
537
+ max_speed=trip.max_speed,
538
+ ),
539
+ day_list=[],
540
+ )
541
+ month_trip_info_count = 1
542
+ else:
543
+ # increment totals for month (for the few trips available)
544
+ month_trip_info_count += 1
545
+ summary = month_trip_info.summary
546
+ summary.drive_time += trip.drive_time
547
+ summary.idle_time += trip.idle_time
548
+ summary.distance += trip.distance
549
+ summary.avg_speed += trip.avg_speed
550
+ summary.max_speed = max(trip.max_speed, summary.max_speed)
551
+
552
+ month_trip_info.summary.avg_speed /= month_trip_info_count
553
+ month_trip_info.summary.avg_speed = round(
554
+ month_trip_info.summary.avg_speed, 1
555
+ )
556
+
557
+ # also fill DayTripCount
558
+ yyyymmdd = yyyymm + date_str[8:10]
559
+ day_trip_found = False
560
+ for day in month_trip_info.day_list:
561
+ if day.yyyymmdd == yyyymmdd:
562
+ day.trip_count += 1
563
+ day_trip_found = True
564
+
565
+ if not day_trip_found:
566
+ month_trip_info.day_list.append(
567
+ DayTripCounts(yyyymmdd=yyyymmdd, trip_count=1)
568
+ )
569
+
570
+ vehicle.month_trip_info = month_trip_info
571
+
572
+ def update_day_trip_info(
573
+ self,
574
+ token,
575
+ vehicle,
576
+ yyyymmdd_string,
577
+ ) -> None:
578
+ """
579
+ feature only available for some regions.
580
+ Updates the vehicle.day_trip_info information for the specified day.
581
+
582
+ Default this information is None:
583
+
584
+ day_trip_info: DayTripInfo = None
585
+ """
586
+ _LOGGER.debug(f"update_day_trip_info: {yyyymmdd_string}")
587
+ vehicle.day_trip_info = None
588
+
589
+ if vehicle.data is None or "filled_trips" not in vehicle.data:
590
+ _LOGGER.debug(f"filled_trips is empty: {vehicle.data}")
591
+ return # nothing to fill
592
+
593
+ trips = vehicle.data["filled_trips"]
594
+ _LOGGER.debug(f"filled_trips: {trips}")
595
+
596
+ day_trip_info: DayTripInfo = None
597
+ day_trip_info_count = 0
598
+
599
+ for trip in trips:
600
+ date_str = trip.hhmmss
601
+ yyyymmdd = date_str[0:4] + date_str[5:7] + date_str[8:10]
602
+ _LOGGER.debug(f"update_day_trip_info: {yyyymmdd} trip: {trip}")
603
+ if yyyymmdd == yyyymmdd_string:
604
+ if day_trip_info_count == 0:
605
+ day_trip_info = DayTripInfo(
606
+ yyyymmdd=yyyymmdd_string,
607
+ summary=TripInfo(
608
+ drive_time=trip.drive_time,
609
+ idle_time=trip.idle_time,
610
+ distance=trip.distance,
611
+ avg_speed=trip.avg_speed,
612
+ max_speed=trip.max_speed,
613
+ ),
614
+ trip_list=[],
615
+ )
616
+ day_trip_info_count = 1
617
+ else:
618
+ # increment totals for month (for the few trips available)
619
+ day_trip_info_count += 1
620
+ summary = day_trip_info.summary
621
+ summary.drive_time += trip.drive_time
622
+ summary.idle_time += trip.idle_time
623
+ summary.distance += trip.distance
624
+ summary.avg_speed += trip.avg_speed
625
+ summary.max_speed = max(trip.max_speed, summary.max_speed)
626
+
627
+ day_trip_info.summary.avg_speed /= day_trip_info_count
628
+ day_trip_info.summary.avg_speed = round(
629
+ day_trip_info.summary.avg_speed, 1
630
+ )
631
+
632
+ # also fill TripInfo
633
+ hhmmss = date_str[11:13] + date_str[14:16] + date_str[17:19]
634
+ day_trip_info.trip_list.append(
635
+ TripInfo(
636
+ hhmmss=hhmmss,
637
+ drive_time=trip.drive_time,
638
+ idle_time=trip.idle_time,
639
+ distance=trip.distance,
640
+ avg_speed=trip.avg_speed,
641
+ max_speed=trip.max_speed,
642
+ )
643
+ )
644
+ _LOGGER.debug(
645
+ f"update_day_trip_info: trip_list result: {day_trip_info.trip_list}"
646
+ )
647
+
648
+ vehicle.day_trip_info = day_trip_info
649
+
471
650
  def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> None:
472
651
  state = {}
473
652
  state["vehicleDetails"] = self._get_vehicle_details(token, vehicle)
@@ -965,6 +965,7 @@ class KiaUvoApiAU(ApiImplType1):
965
965
  battery_care_consumption=day["batteryMgPwrCsp"],
966
966
  regenerated_energy=day["regenPwr"],
967
967
  distance=day["calculativeOdo"],
968
+ distance_unit=vehicle.odometer_unit,
968
969
  )
969
970
  drivingInfo["dailyStats"].append(processedDay)
970
971
 
@@ -947,6 +947,7 @@ class KiaUvoApiCN(ApiImplType1):
947
947
  battery_care_consumption=day["batteryMgPwrCsp"],
948
948
  regenerated_energy=day["regenPwr"],
949
949
  distance=day["calculativeOdo"],
950
+ distance_unit=vehicle.odometer_unit,
950
951
  )
951
952
  drivingInfo["dailyStats"].append(processedDay)
952
953
 
@@ -1216,6 +1216,7 @@ class KiaUvoApiEU(ApiImplType1):
1216
1216
  ),
1217
1217
  regenerated_energy=get_child_value(day, "regenPwr"),
1218
1218
  distance=get_child_value(day, "calculativeOdo"),
1219
+ distance_unit=vehicle.odometer_unit,
1219
1220
  )
1220
1221
  drivingInfo["dailyStats"].append(processedDay)
1221
1222
 
@@ -63,7 +63,7 @@ class DailyDrivingStats:
63
63
  # distance is expressed in (I assume) whatever unit the vehicle is
64
64
  # configured in. KMs (rounded) in my case
65
65
  distance: int = None
66
- distance_unit = DISTANCE_UNITS[1] # set to kms by default
66
+ distance_unit: str = DISTANCE_UNITS[1] # set to kms by default
67
67
 
68
68
 
69
69
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.22.9
3
+ Version: 3.23.0
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/fuatakgun/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -44,6 +44,6 @@ setup(
44
44
  test_suite="tests",
45
45
  tests_require=test_requirements,
46
46
  url="https://github.com/fuatakgun/hyundai_kia_connect_api",
47
- version="3.22.9",
47
+ version="3.23.0",
48
48
  zip_safe=False,
49
49
  )