hyundai-kia-connect-api 3.23.8__py2.py3-none-any.whl → 3.24.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.
@@ -12,6 +12,8 @@ import certifi
12
12
  from requests.adapters import HTTPAdapter
13
13
  from urllib3.util.ssl_ import create_urllib3_context
14
14
 
15
+ from hyundai_kia_connect_api.exceptions import APIError
16
+
15
17
  from .const import (
16
18
  DOMAIN,
17
19
  VEHICLE_LOCK_ACTION,
@@ -459,6 +461,31 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
459
461
  # fill vehicle.daily_stats
460
462
  tripStats = []
461
463
  tripDetails = get_child_value(state, "evTripDetails.tripdetails") or {}
464
+
465
+ # compute more digits for distance mileage using odometer and overrule distance
466
+ previous_odometer = None
467
+ for trip in reversed(tripDetails):
468
+ odometer = get_child_value(trip, "odometer.value")
469
+ if previous_odometer and odometer:
470
+ delta_odometer = odometer - previous_odometer
471
+ if delta_odometer >= 0.0:
472
+ trip["distance"] = delta_odometer
473
+ previous_odometer = odometer
474
+
475
+ # overrule odometer with more accuracy from last trip
476
+ if (
477
+ previous_odometer
478
+ and vehicle.odometer
479
+ and previous_odometer > vehicle.odometer
480
+ ):
481
+ _LOGGER.debug(
482
+ f"Overruling odometer: {previous_odometer:.1f} old: {vehicle.odometer:.1f}" # noqa
483
+ )
484
+ vehicle.odometer = (
485
+ previous_odometer,
486
+ DISTANCE_UNITS[3],
487
+ )
488
+
462
489
  for trip in tripDetails:
463
490
  processedTrip = DailyDrivingStats(
464
491
  date=dt.datetime.strptime(trip["startdate"], "%Y-%m-%d %H:%M:%S.%f"),
@@ -485,7 +512,7 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
485
512
  hhmmss=yyyymmdd_hhmmss,
486
513
  drive_time=int(drive_time / 60), # convert seconds to minutes
487
514
  idle_time=int(idle_time / 60), # convert seconds to minutes
488
- distance=int(trip["distance"]),
515
+ distance=float(trip["distance"]),
489
516
  avg_speed=get_child_value(trip["avgspeed"], "value"),
490
517
  max_speed=int(get_child_value(trip["maxspeed"], "value")),
491
518
  )
@@ -733,6 +760,8 @@ class HyundaiBlueLinkAPIUSA(ApiImpl):
733
760
  elif action == VEHICLE_LOCK_ACTION.UNLOCK:
734
761
  url = self.API_URL + "rcs/rdo/on"
735
762
  _LOGGER.debug(f"{DOMAIN} - Calling unlock")
763
+ else:
764
+ raise APIError(f"Invalid action value: {action}")
736
765
 
737
766
  headers = self._get_vehicle_headers(token, vehicle)
738
767
  headers["APPCLOUD-VIN"] = vehicle.VIN
@@ -124,8 +124,14 @@ class KiaUvoAPIUSA(ApiImpl):
124
124
 
125
125
  self.BASE_URL: str = "api.owners.kia.com"
126
126
  self.API_URL: str = "https://" + self.BASE_URL + "/apigw/v1/"
127
- self.session = requests.Session()
128
- self.session.mount("https://", KiaSSLAdapter())
127
+ self._session = None
128
+
129
+ @property
130
+ def session(self):
131
+ if not self._session:
132
+ self._session = requests.Session()
133
+ self._session.mount("https://", KiaSSLAdapter())
134
+ return self._session
129
135
 
130
136
  def api_headers(self) -> dict:
131
137
  offset = time.localtime().tm_gmtoff / 60 / 60
@@ -653,8 +659,9 @@ class KiaUvoAPIUSA(ApiImpl):
653
659
  },
654
660
  }
655
661
 
656
- # Kia seems to now be checking if you can set the heated/vented seats at the car level
657
- # only add to body if the option is not none for any of the seats
662
+ # Kia seems to now be checking if you can set the heated/vented seats at
663
+ # the car level only add to body if the option is not none for any of
664
+ # the seats
658
665
  if (
659
666
  options.front_left_seat is not None
660
667
  or options.front_right_seat is not None
@@ -95,8 +95,14 @@ class KiaUvoApiCA(ApiImpl):
95
95
  "sec-fetch-mode": "cors",
96
96
  "sec-fetch-site": "same-origin",
97
97
  }
98
- self.sessions = requests.Session()
99
- self.sessions.mount("https://" + self.BASE_URL, cipherAdapter())
98
+ self._sessions = None
99
+
100
+ @property
101
+ def sessions(self):
102
+ if not self._sessions:
103
+ self._sessions = requests.Session()
104
+ self._sessions.mount("https://" + self.BASE_URL, cipherAdapter())
105
+ return self._sessions
100
106
 
101
107
  def _check_response_for_errors(self, response: dict) -> None:
102
108
  """
@@ -19,7 +19,7 @@ class TripInfo:
19
19
  hhmmss: str = None # will not be filled by summary
20
20
  drive_time: int = None # minutes
21
21
  idle_time: int = None # minutes
22
- distance: int = None
22
+ distance: float = None
23
23
  avg_speed: float = None
24
24
  max_speed: int = None
25
25
 
@@ -60,9 +60,7 @@ class DailyDrivingStats:
60
60
  onboard_electronics_consumption: int = None
61
61
  battery_care_consumption: int = None
62
62
  regenerated_energy: int = None
63
- # distance is expressed in (I assume) whatever unit the vehicle is
64
- # configured in. KMs (rounded) in my case
65
- distance: int = None
63
+ distance: float = None
66
64
  distance_unit: str = DISTANCE_UNITS[1] # set to kms by default
67
65
 
68
66
 
@@ -2,17 +2,10 @@
2
2
 
3
3
  # flake8: noqa
4
4
  from .ApiImpl import (
5
- ApiImpl,
6
5
  ClimateRequestOptions,
7
6
  WindowRequestOptions,
8
7
  ScheduleChargingClimateRequestOptions,
9
8
  )
10
- from .ApiImplType1 import ApiImplType1
11
- from .HyundaiBlueLinkAPIUSA import HyundaiBlueLinkAPIUSA
12
- from .KiaUvoApiCA import KiaUvoApiCA
13
- from .KiaUvoApiEU import KiaUvoApiEU
14
- from .KiaUvoAPIUSA import KiaUvoAPIUSA
15
- from .KiaUvoApiCN import KiaUvoApiCN
16
9
 
17
10
  from .Token import Token
18
11
  from .Vehicle import Vehicle
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.23.8
3
+ Version: 3.24.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,21 +1,21 @@
1
1
  hyundai_kia_connect_api/ApiImpl.py,sha256=7tB6PZTEVlw-GCfEjU4ekq_ZgnFseYLrEYpbUyEoL84,6866
2
2
  hyundai_kia_connect_api/ApiImplType1.py,sha256=PnKwpbCoYGOXBWzBLIlDSrC6daIYeW9qlfW7TM4HCU0,12184
3
- hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py,sha256=xHUpj-1bzHQL4w82kRAt9FMB8ze_DoqZinK6djCyeKY,35619
4
- hyundai_kia_connect_api/KiaUvoAPIUSA.py,sha256=Cvkjat13g4AmETUxjpLkwCnB9i0Unck2jKExOCsPjcw,31146
3
+ hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py,sha256=MK1cFcnuZebogz32-nXjHt0pAgQ1-2lrurw8SADX6ww,36690
4
+ hyundai_kia_connect_api/KiaUvoAPIUSA.py,sha256=FmRc7bAmsOz9jBtWSAb8lD0ybRMN0OgfEPZZJbPhMUw,31292
5
5
  hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=Mzw0Ov5la4mQvWOXWYpvAfrM6l2BSBEusaPFsL3kn2I,48127
6
- hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=DXXjtS2Dpb7zy6BmhhMLpfxwXwx7ulBEjFRA__bxXhI,30623
6
+ hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=B3Lks_ONr3l01QLl-GQBPdktXj9PZWKuQKRLYmJ7kP4,30763
7
7
  hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
8
8
  hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=_wNkctkIO2hrf1K2LTZPtHWZ5ewTcXqTv0s_AXRXI2I,68254
9
9
  hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
10
- hyundai_kia_connect_api/Vehicle.py,sha256=s_AkDxiQ8vS1CCxLn1H5W15WGLnhPIWUdnkYdXuNLxw,18752
10
+ hyundai_kia_connect_api/Vehicle.py,sha256=M95Eq1vK-th5se7dZHEDcTOM1b19GIjpecyw2MKykQ8,18639
11
11
  hyundai_kia_connect_api/VehicleManager.py,sha256=REny83eNXERAcnw8qrBZ9dh6qODCvd5Z_jmSY2JtXvY,10196
12
- hyundai_kia_connect_api/__init__.py,sha256=i2kXYjBEKSvT1e8FoQ7V7oqAyL22w3XzF2rAFpyietc,578
12
+ hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
13
13
  hyundai_kia_connect_api/const.py,sha256=ofi_ZfGxJYo0FWIcGFbIMSMRdKRtaK4GUDhFiQRvZeI,2007
14
14
  hyundai_kia_connect_api/exceptions.py,sha256=m7gyDnvA5OVAK4EXSP_ZwE0s0uV8HsGUV0tiYwqofK0,1343
15
15
  hyundai_kia_connect_api/utils.py,sha256=J0aXUX-nKIoS3XbelatNh-DZlHRU2_DYz_Mg_ZUKQJU,1957
16
- hyundai_kia_connect_api-3.23.8.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
17
- hyundai_kia_connect_api-3.23.8.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
18
- hyundai_kia_connect_api-3.23.8.dist-info/METADATA,sha256=mhuM__ujhUV2Or4owDeYX9PEMbUOc39HyzDmtiCqeuw,6069
19
- hyundai_kia_connect_api-3.23.8.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
20
- hyundai_kia_connect_api-3.23.8.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
21
- hyundai_kia_connect_api-3.23.8.dist-info/RECORD,,
16
+ hyundai_kia_connect_api-3.24.0.dist-info/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
17
+ hyundai_kia_connect_api-3.24.0.dist-info/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
18
+ hyundai_kia_connect_api-3.24.0.dist-info/METADATA,sha256=0rSDOZXPXAEl9DWh4K8tYoiPulu3WMSWaMy4vI_hkeY,6069
19
+ hyundai_kia_connect_api-3.24.0.dist-info/WHEEL,sha256=OpXWERl2xLPRHTvd2ZXo_iluPEQd8uSbYkJ53NAER_Y,109
20
+ hyundai_kia_connect_api-3.24.0.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
21
+ hyundai_kia_connect_api-3.24.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any