hyundai-kia-connect-api 3.34.2__py2.py3-none-any.whl → 3.34.4__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.
- hyundai_kia_connect_api/ApiImpl.py +2 -2
- hyundai_kia_connect_api/ApiImplType1.py +179 -3
- hyundai_kia_connect_api/KiaUvoApiAU.py +0 -59
- hyundai_kia_connect_api/KiaUvoApiCA.py +7 -7
- hyundai_kia_connect_api/KiaUvoApiCN.py +8 -8
- hyundai_kia_connect_api/KiaUvoApiEU.py +0 -178
- hyundai_kia_connect_api/KiaUvoApiUSA.py +2 -2
- hyundai_kia_connect_api/VehicleManager.py +2 -2
- hyundai_kia_connect_api/const.py +1 -1
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/METADATA +1 -1
- hyundai_kia_connect_api-3.34.4.dist-info/RECORD +23 -0
- hyundai_kia_connect_api-3.34.2.dist-info/RECORD +0 -23
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/WHEEL +0 -0
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/entry_points.txt +0 -0
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/licenses/AUTHORS.rst +0 -0
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/licenses/LICENSE +0 -0
- {hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/top_level.txt +0 -0
@@ -15,7 +15,7 @@ from .Vehicle import Vehicle
|
|
15
15
|
from .const import (
|
16
16
|
WINDOW_STATE,
|
17
17
|
CHARGE_PORT_ACTION,
|
18
|
-
|
18
|
+
ORDER_STATUS,
|
19
19
|
DOMAIN,
|
20
20
|
VALET_MODE_ACTION,
|
21
21
|
VEHICLE_LOCK_ACTION,
|
@@ -107,7 +107,7 @@ class ApiImpl:
|
|
107
107
|
action_id: str,
|
108
108
|
synchronous: bool = False,
|
109
109
|
timeout: int = 0,
|
110
|
-
) ->
|
110
|
+
) -> ORDER_STATUS:
|
111
111
|
pass
|
112
112
|
|
113
113
|
def force_refresh_vehicle_state(self, token: Token, vehicle: Vehicle) -> None:
|
@@ -5,9 +5,10 @@ import requests
|
|
5
5
|
import logging
|
6
6
|
from typing import Optional
|
7
7
|
|
8
|
-
from
|
9
|
-
|
10
|
-
|
8
|
+
from time import sleep
|
9
|
+
|
10
|
+
|
11
|
+
from .ApiImpl import ApiImpl, ScheduleChargingClimateRequestOptions
|
11
12
|
from .Token import Token
|
12
13
|
from .Vehicle import Vehicle
|
13
14
|
|
@@ -23,6 +24,7 @@ from .const import (
|
|
23
24
|
SEAT_STATUS,
|
24
25
|
TEMPERATURE_UNITS,
|
25
26
|
VEHICLE_LOCK_ACTION,
|
27
|
+
ORDER_STATUS,
|
26
28
|
)
|
27
29
|
|
28
30
|
from .exceptions import (
|
@@ -528,3 +530,177 @@ class ApiImplType1(ApiImpl):
|
|
528
530
|
_check_response_for_errors(response)
|
529
531
|
token.device_id = self._get_device_id(self._get_stamp())
|
530
532
|
return response["msgId"]
|
533
|
+
|
534
|
+
def check_action_status(
|
535
|
+
self,
|
536
|
+
token: Token,
|
537
|
+
vehicle: Vehicle,
|
538
|
+
action_id: str,
|
539
|
+
synchronous: bool = False,
|
540
|
+
timeout: int = 0,
|
541
|
+
) -> ORDER_STATUS:
|
542
|
+
url = self.SPA_API_URL + "notifications/" + vehicle.id + "/records"
|
543
|
+
|
544
|
+
if synchronous:
|
545
|
+
if timeout < 1:
|
546
|
+
raise APIError("Timeout must be 1 or higher")
|
547
|
+
|
548
|
+
end_time = dt.datetime.now() + dt.timedelta(seconds=timeout)
|
549
|
+
while end_time > dt.datetime.now():
|
550
|
+
# recursive call with Synchronous set to False
|
551
|
+
state = self.check_action_status(
|
552
|
+
token, vehicle, action_id, synchronous=False
|
553
|
+
)
|
554
|
+
if state == ORDER_STATUS.PENDING:
|
555
|
+
# state pending: recheck regularly
|
556
|
+
# (until we get a final state or exceed the timeout)
|
557
|
+
sleep(5)
|
558
|
+
else:
|
559
|
+
# any other state is final
|
560
|
+
return state
|
561
|
+
|
562
|
+
# if we exit the loop after the set timeout, return a Timeout state
|
563
|
+
return ORDER_STATUS.TIMEOUT
|
564
|
+
|
565
|
+
else:
|
566
|
+
response = requests.get(
|
567
|
+
url,
|
568
|
+
headers=self._get_authenticated_headers(
|
569
|
+
token, vehicle.ccu_ccs2_protocol_support
|
570
|
+
),
|
571
|
+
).json()
|
572
|
+
_LOGGER.debug(f"{DOMAIN} - Check last action status Response: {response}")
|
573
|
+
_check_response_for_errors(response)
|
574
|
+
|
575
|
+
for action in response["resMsg"]:
|
576
|
+
if action["recordId"] == action_id:
|
577
|
+
if action["result"] == "success":
|
578
|
+
return ORDER_STATUS.SUCCESS
|
579
|
+
elif action["result"] == "fail":
|
580
|
+
return ORDER_STATUS.FAILED
|
581
|
+
elif action["result"] == "non-response":
|
582
|
+
return ORDER_STATUS.TIMEOUT
|
583
|
+
elif action["result"] is None:
|
584
|
+
_LOGGER.info(
|
585
|
+
"Action status not set yet by server - try again in a few seconds" # noqa
|
586
|
+
)
|
587
|
+
return ORDER_STATUS.PENDING
|
588
|
+
|
589
|
+
# if iterate the whole notifications list and
|
590
|
+
# can't find the action, raise an exception
|
591
|
+
# Old code: raise APIError(f"No action found with ID {action_id}")
|
592
|
+
return ORDER_STATUS.UNKNOWN
|
593
|
+
|
594
|
+
def schedule_charging_and_climate(
|
595
|
+
self,
|
596
|
+
token: Token,
|
597
|
+
vehicle: Vehicle,
|
598
|
+
options: ScheduleChargingClimateRequestOptions,
|
599
|
+
) -> str:
|
600
|
+
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id
|
601
|
+
url = url + "/ccs2" # does not depend on vehicle.ccu_ccs2_protocol_support
|
602
|
+
url = url + "/reservation/chargehvac"
|
603
|
+
|
604
|
+
def set_default_departure_options(
|
605
|
+
departure_options: ScheduleChargingClimateRequestOptions.DepartureOptions,
|
606
|
+
) -> None:
|
607
|
+
if departure_options.enabled is None:
|
608
|
+
departure_options.enabled = False
|
609
|
+
if departure_options.days is None:
|
610
|
+
departure_options.days = [0]
|
611
|
+
if departure_options.time is None:
|
612
|
+
departure_options.time = dt.time()
|
613
|
+
|
614
|
+
if options.first_departure is None:
|
615
|
+
options.first_departure = (
|
616
|
+
ScheduleChargingClimateRequestOptions.DepartureOptions()
|
617
|
+
)
|
618
|
+
if options.second_departure is None:
|
619
|
+
options.second_departure = (
|
620
|
+
ScheduleChargingClimateRequestOptions.DepartureOptions()
|
621
|
+
)
|
622
|
+
|
623
|
+
set_default_departure_options(options.first_departure)
|
624
|
+
set_default_departure_options(options.second_departure)
|
625
|
+
departures = [options.first_departure, options.second_departure]
|
626
|
+
|
627
|
+
if options.charging_enabled is None:
|
628
|
+
options.charging_enabled = False
|
629
|
+
if options.off_peak_start_time is None:
|
630
|
+
options.off_peak_start_time = dt.time()
|
631
|
+
if options.off_peak_end_time is None:
|
632
|
+
options.off_peak_end_time = options.off_peak_start_time
|
633
|
+
if options.off_peak_charge_only_enabled is None:
|
634
|
+
options.off_peak_charge_only_enabled = False
|
635
|
+
if options.climate_enabled is None:
|
636
|
+
options.climate_enabled = False
|
637
|
+
if options.temperature is None:
|
638
|
+
options.temperature = 21.0
|
639
|
+
if options.temperature_unit is None:
|
640
|
+
options.temperature_unit = 0
|
641
|
+
if options.defrost is None:
|
642
|
+
options.defrost = False
|
643
|
+
|
644
|
+
temperature: float = options.temperature
|
645
|
+
if options.temperature_unit == 0:
|
646
|
+
# Round to nearest 0.5
|
647
|
+
temperature = round(temperature * 2.0) / 2.0
|
648
|
+
# Cap at 27, floor at 17
|
649
|
+
if temperature > 27.0:
|
650
|
+
temperature = 27.0
|
651
|
+
elif temperature < 17.0:
|
652
|
+
temperature = 17.0
|
653
|
+
|
654
|
+
payload = {
|
655
|
+
"reservChargeInfo" + str(i + 1): {
|
656
|
+
"reservChargeSet": departures[i].enabled,
|
657
|
+
"reservInfo": {
|
658
|
+
"day": departures[i].days,
|
659
|
+
"time": {
|
660
|
+
"time": departures[i].time.strftime("%I%M"),
|
661
|
+
"timeSection": 1 if departures[i].time >= dt.time(12, 0) else 0,
|
662
|
+
},
|
663
|
+
},
|
664
|
+
"reservFatcSet": {
|
665
|
+
"airCtrl": 1 if options.climate_enabled else 0,
|
666
|
+
"airTemp": {
|
667
|
+
"value": f"{temperature:.1f}",
|
668
|
+
"hvacTempType": 1,
|
669
|
+
"unit": options.temperature_unit,
|
670
|
+
},
|
671
|
+
"heating1": 0,
|
672
|
+
"defrost": options.defrost,
|
673
|
+
},
|
674
|
+
}
|
675
|
+
for i in range(2)
|
676
|
+
}
|
677
|
+
|
678
|
+
payload = payload | {
|
679
|
+
"offPeakPowerInfo": {
|
680
|
+
"offPeakPowerTime1": {
|
681
|
+
"endtime": {
|
682
|
+
"timeSection": (
|
683
|
+
1 if options.off_peak_end_time >= dt.time(12, 0) else 0
|
684
|
+
),
|
685
|
+
"time": options.off_peak_end_time.strftime("%I%M"),
|
686
|
+
},
|
687
|
+
"starttime": {
|
688
|
+
"timeSection": (
|
689
|
+
1 if options.off_peak_start_time >= dt.time(12, 0) else 0
|
690
|
+
),
|
691
|
+
"time": options.off_peak_start_time.strftime("%I%M"),
|
692
|
+
},
|
693
|
+
},
|
694
|
+
"offPeakPowerFlag": 2 if options.off_peak_charge_only_enabled else 1,
|
695
|
+
},
|
696
|
+
"reservFlag": 1 if options.charging_enabled else 0,
|
697
|
+
}
|
698
|
+
|
699
|
+
_LOGGER.debug(f"{DOMAIN} - Schedule Charging and Climate Request: {payload}")
|
700
|
+
response = requests.post(
|
701
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
702
|
+
).json()
|
703
|
+
_LOGGER.debug(f"{DOMAIN} - Schedule Charging and Climate Response: {response}")
|
704
|
+
_check_response_for_errors(response)
|
705
|
+
token.device_id = self._get_device_id(self._get_stamp())
|
706
|
+
return response["msgId"]
|
@@ -8,7 +8,6 @@ import math
|
|
8
8
|
import logging
|
9
9
|
import random
|
10
10
|
import uuid
|
11
|
-
from time import sleep
|
12
11
|
from urllib.parse import parse_qs, urlparse
|
13
12
|
|
14
13
|
import pytz
|
@@ -40,11 +39,9 @@ from .const import (
|
|
40
39
|
SEAT_STATUS,
|
41
40
|
CHARGE_PORT_ACTION,
|
42
41
|
ENGINE_TYPES,
|
43
|
-
OrderStatus,
|
44
42
|
)
|
45
43
|
from .exceptions import (
|
46
44
|
AuthenticationError,
|
47
|
-
APIError,
|
48
45
|
)
|
49
46
|
from .utils import (
|
50
47
|
get_child_value,
|
@@ -1063,59 +1060,3 @@ class KiaUvoApiAU(ApiImplType1):
|
|
1063
1060
|
dt.datetime.now().timestamp() + response["expiresTime"]
|
1064
1061
|
)
|
1065
1062
|
return control_token, control_token_expire_at
|
1066
|
-
|
1067
|
-
def check_action_status(
|
1068
|
-
self,
|
1069
|
-
token: Token,
|
1070
|
-
vehicle: Vehicle,
|
1071
|
-
action_id: str,
|
1072
|
-
synchronous: bool = False,
|
1073
|
-
timeout: int = 0,
|
1074
|
-
) -> OrderStatus:
|
1075
|
-
url = self.SPA_API_URL + "notifications/" + vehicle.id + "/records"
|
1076
|
-
|
1077
|
-
if synchronous:
|
1078
|
-
if timeout < 1:
|
1079
|
-
raise APIError("Timeout must be 1 or higher")
|
1080
|
-
|
1081
|
-
end_time = dt.datetime.now() + dt.timedelta(seconds=timeout)
|
1082
|
-
while end_time > dt.datetime.now():
|
1083
|
-
# recursive call with Synchronous set to False
|
1084
|
-
state = self.check_action_status(
|
1085
|
-
token, vehicle, action_id, synchronous=False
|
1086
|
-
)
|
1087
|
-
if state == OrderStatus.PENDING:
|
1088
|
-
# state pending: recheck regularly
|
1089
|
-
# (until we get a final state or exceed the timeout)
|
1090
|
-
sleep(5)
|
1091
|
-
else:
|
1092
|
-
# any other state is final
|
1093
|
-
return state
|
1094
|
-
|
1095
|
-
# if we exit the loop after the set timeout, return a Timeout state
|
1096
|
-
return OrderStatus.TIMEOUT
|
1097
|
-
|
1098
|
-
else:
|
1099
|
-
response = requests.get(
|
1100
|
-
url, headers=self._get_authenticated_headers(token)
|
1101
|
-
).json()
|
1102
|
-
_LOGGER.debug(f"{DOMAIN} - Check last action status Response: {response}")
|
1103
|
-
_check_response_for_errors(response)
|
1104
|
-
|
1105
|
-
for action in response["resMsg"]:
|
1106
|
-
if action["recordId"] == action_id:
|
1107
|
-
if action["result"] == "success":
|
1108
|
-
return OrderStatus.SUCCESS
|
1109
|
-
elif action["result"] == "fail":
|
1110
|
-
return OrderStatus.FAILED
|
1111
|
-
elif action["result"] == "non-response":
|
1112
|
-
return OrderStatus.TIMEOUT
|
1113
|
-
elif action["result"] is None:
|
1114
|
-
_LOGGER.debug(
|
1115
|
-
"Action status not set yet by server - try again in a few seconds" # noqa
|
1116
|
-
)
|
1117
|
-
return OrderStatus.PENDING
|
1118
|
-
|
1119
|
-
# if iterate the whole notifications list and
|
1120
|
-
# can't find the action, raise an exception
|
1121
|
-
raise APIError(f"No action found with ID {action_id}")
|
@@ -22,7 +22,7 @@ from .const import (
|
|
22
22
|
DISTANCE_UNITS,
|
23
23
|
DOMAIN,
|
24
24
|
ENGINE_TYPES,
|
25
|
-
|
25
|
+
ORDER_STATUS,
|
26
26
|
SEAT_STATUS,
|
27
27
|
TEMPERATURE_UNITS,
|
28
28
|
VEHICLE_LOCK_ACTION,
|
@@ -677,9 +677,9 @@ class KiaUvoApiCA(ApiImpl):
|
|
677
677
|
action_id: str,
|
678
678
|
synchronous: bool = False,
|
679
679
|
timeout: int = 0,
|
680
|
-
) ->
|
680
|
+
) -> ORDER_STATUS:
|
681
681
|
if timeout < 0:
|
682
|
-
return
|
682
|
+
return ORDER_STATUS.TIMEOUT
|
683
683
|
start_time = dt.datetime.now()
|
684
684
|
|
685
685
|
url = self.API_URL + "rmtsts"
|
@@ -700,12 +700,12 @@ class KiaUvoApiCA(ApiImpl):
|
|
700
700
|
_LOGGER.debug(f"{DOMAIN} - Last action_status: {action_status}")
|
701
701
|
|
702
702
|
if response["responseHeader"]["responseCode"] == 1:
|
703
|
-
return
|
703
|
+
return ORDER_STATUS.FAILED
|
704
704
|
elif response["result"]["transaction"]["apiResult"] == "C":
|
705
|
-
return
|
705
|
+
return ORDER_STATUS.SUCCESS
|
706
706
|
elif response["result"]["transaction"]["apiResult"] == "P":
|
707
707
|
if not synchronous:
|
708
|
-
return
|
708
|
+
return ORDER_STATUS.PENDING
|
709
709
|
else:
|
710
710
|
timedelta = dt.datetime.now() - start_time
|
711
711
|
time_left = timeout - timedelta.seconds - 10
|
@@ -714,7 +714,7 @@ class KiaUvoApiCA(ApiImpl):
|
|
714
714
|
token, vehicle, action_id, synchronous, time_left
|
715
715
|
)
|
716
716
|
|
717
|
-
return
|
717
|
+
return ORDER_STATUS.FAILED
|
718
718
|
|
719
719
|
def start_charge(self, token: Token, vehicle: Vehicle) -> str:
|
720
720
|
url = self.API_URL + "evc/rcstrt"
|
@@ -37,7 +37,7 @@ from .const import (
|
|
37
37
|
DOMAIN,
|
38
38
|
ENGINE_TYPES,
|
39
39
|
LOGIN_TOKEN_LIFETIME,
|
40
|
-
|
40
|
+
ORDER_STATUS,
|
41
41
|
SEAT_STATUS,
|
42
42
|
TEMPERATURE_UNITS,
|
43
43
|
VEHICLE_LOCK_ACTION,
|
@@ -1143,7 +1143,7 @@ class KiaUvoApiCN(ApiImplType1):
|
|
1143
1143
|
action_id: str,
|
1144
1144
|
synchronous: bool = False,
|
1145
1145
|
timeout: int = 0,
|
1146
|
-
) ->
|
1146
|
+
) -> ORDER_STATUS:
|
1147
1147
|
url = self.SPA_API_URL + "notifications/" + vehicle.id + "/records"
|
1148
1148
|
|
1149
1149
|
if synchronous:
|
@@ -1156,7 +1156,7 @@ class KiaUvoApiCN(ApiImplType1):
|
|
1156
1156
|
state = self.check_action_status(
|
1157
1157
|
token, vehicle, action_id, synchronous=False
|
1158
1158
|
)
|
1159
|
-
if state ==
|
1159
|
+
if state == ORDER_STATUS.PENDING:
|
1160
1160
|
# state pending: recheck regularly
|
1161
1161
|
# (until we get a final state or exceed the timeout)
|
1162
1162
|
sleep(5)
|
@@ -1165,7 +1165,7 @@ class KiaUvoApiCN(ApiImplType1):
|
|
1165
1165
|
return state
|
1166
1166
|
|
1167
1167
|
# if we exit the loop after the set timeout, return a Timeout state
|
1168
|
-
return
|
1168
|
+
return ORDER_STATUS.TIMEOUT
|
1169
1169
|
|
1170
1170
|
else:
|
1171
1171
|
response = requests.get(
|
@@ -1177,16 +1177,16 @@ class KiaUvoApiCN(ApiImplType1):
|
|
1177
1177
|
for action in response["resMsg"]:
|
1178
1178
|
if action["recordId"] == action_id:
|
1179
1179
|
if action["result"] == "success":
|
1180
|
-
return
|
1180
|
+
return ORDER_STATUS.SUCCESS
|
1181
1181
|
elif action["result"] == "fail":
|
1182
|
-
return
|
1182
|
+
return ORDER_STATUS.FAILED
|
1183
1183
|
elif action["result"] == "non-response":
|
1184
|
-
return
|
1184
|
+
return ORDER_STATUS.TIMEOUT
|
1185
1185
|
elif action["result"] is None:
|
1186
1186
|
_LOGGER.debug(
|
1187
1187
|
"Action status not set yet by server - try again in a few seconds" # noqa
|
1188
1188
|
)
|
1189
|
-
return
|
1189
|
+
return ORDER_STATUS.PENDING
|
1190
1190
|
|
1191
1191
|
# if iterate the whole notifications list and
|
1192
1192
|
# can't find the action, raise an exception
|
@@ -8,7 +8,6 @@ import datetime as dt
|
|
8
8
|
import logging
|
9
9
|
import uuid
|
10
10
|
import math
|
11
|
-
from time import sleep
|
12
11
|
from urllib.parse import parse_qs, urlparse
|
13
12
|
|
14
13
|
import pytz
|
@@ -18,7 +17,6 @@ from dateutil import tz
|
|
18
17
|
|
19
18
|
from .ApiImpl import (
|
20
19
|
ClimateRequestOptions,
|
21
|
-
ScheduleChargingClimateRequestOptions,
|
22
20
|
)
|
23
21
|
from .ApiImplType1 import ApiImplType1
|
24
22
|
from .ApiImplType1 import _check_response_for_errors
|
@@ -42,14 +40,12 @@ from .const import (
|
|
42
40
|
DOMAIN,
|
43
41
|
ENGINE_TYPES,
|
44
42
|
LOGIN_TOKEN_LIFETIME,
|
45
|
-
OrderStatus,
|
46
43
|
SEAT_STATUS,
|
47
44
|
TEMPERATURE_UNITS,
|
48
45
|
VALET_MODE_ACTION,
|
49
46
|
)
|
50
47
|
from .exceptions import (
|
51
48
|
AuthenticationError,
|
52
|
-
APIError,
|
53
49
|
)
|
54
50
|
from .utils import (
|
55
51
|
get_child_value,
|
@@ -1170,120 +1166,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1170
1166
|
)
|
1171
1167
|
return None
|
1172
1168
|
|
1173
|
-
def schedule_charging_and_climate(
|
1174
|
-
self,
|
1175
|
-
token: Token,
|
1176
|
-
vehicle: Vehicle,
|
1177
|
-
options: ScheduleChargingClimateRequestOptions,
|
1178
|
-
) -> str:
|
1179
|
-
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id
|
1180
|
-
url = url + "/ccs2" # does not depend on vehicle.ccu_ccs2_protocol_support
|
1181
|
-
url = url + "/reservation/chargehvac"
|
1182
|
-
|
1183
|
-
def set_default_departure_options(
|
1184
|
-
departure_options: ScheduleChargingClimateRequestOptions.DepartureOptions,
|
1185
|
-
) -> None:
|
1186
|
-
if departure_options.enabled is None:
|
1187
|
-
departure_options.enabled = False
|
1188
|
-
if departure_options.days is None:
|
1189
|
-
departure_options.days = [0]
|
1190
|
-
if departure_options.time is None:
|
1191
|
-
departure_options.time = dt.time()
|
1192
|
-
|
1193
|
-
if options.first_departure is None:
|
1194
|
-
options.first_departure = (
|
1195
|
-
ScheduleChargingClimateRequestOptions.DepartureOptions()
|
1196
|
-
)
|
1197
|
-
if options.second_departure is None:
|
1198
|
-
options.second_departure = (
|
1199
|
-
ScheduleChargingClimateRequestOptions.DepartureOptions()
|
1200
|
-
)
|
1201
|
-
|
1202
|
-
set_default_departure_options(options.first_departure)
|
1203
|
-
set_default_departure_options(options.second_departure)
|
1204
|
-
departures = [options.first_departure, options.second_departure]
|
1205
|
-
|
1206
|
-
if options.charging_enabled is None:
|
1207
|
-
options.charging_enabled = False
|
1208
|
-
if options.off_peak_start_time is None:
|
1209
|
-
options.off_peak_start_time = dt.time()
|
1210
|
-
if options.off_peak_end_time is None:
|
1211
|
-
options.off_peak_end_time = options.off_peak_start_time
|
1212
|
-
if options.off_peak_charge_only_enabled is None:
|
1213
|
-
options.off_peak_charge_only_enabled = False
|
1214
|
-
if options.climate_enabled is None:
|
1215
|
-
options.climate_enabled = False
|
1216
|
-
if options.temperature is None:
|
1217
|
-
options.temperature = 21.0
|
1218
|
-
if options.temperature_unit is None:
|
1219
|
-
options.temperature_unit = 0
|
1220
|
-
if options.defrost is None:
|
1221
|
-
options.defrost = False
|
1222
|
-
|
1223
|
-
temperature: float = options.temperature
|
1224
|
-
if options.temperature_unit == 0:
|
1225
|
-
# Round to nearest 0.5
|
1226
|
-
temperature = round(temperature * 2.0) / 2.0
|
1227
|
-
# Cap at 27, floor at 17
|
1228
|
-
if temperature > 27.0:
|
1229
|
-
temperature = 27.0
|
1230
|
-
elif temperature < 17.0:
|
1231
|
-
temperature = 17.0
|
1232
|
-
|
1233
|
-
payload = {
|
1234
|
-
"reservChargeInfo" + str(i + 1): {
|
1235
|
-
"reservChargeSet": departures[i].enabled,
|
1236
|
-
"reservInfo": {
|
1237
|
-
"day": departures[i].days,
|
1238
|
-
"time": {
|
1239
|
-
"time": departures[i].time.strftime("%I%M"),
|
1240
|
-
"timeSection": 1 if departures[i].time >= dt.time(12, 0) else 0,
|
1241
|
-
},
|
1242
|
-
},
|
1243
|
-
"reservFatcSet": {
|
1244
|
-
"airCtrl": 1 if options.climate_enabled else 0,
|
1245
|
-
"airTemp": {
|
1246
|
-
"value": f"{temperature:.1f}",
|
1247
|
-
"hvacTempType": 1,
|
1248
|
-
"unit": options.temperature_unit,
|
1249
|
-
},
|
1250
|
-
"heating1": 0,
|
1251
|
-
"defrost": options.defrost,
|
1252
|
-
},
|
1253
|
-
}
|
1254
|
-
for i in range(2)
|
1255
|
-
}
|
1256
|
-
|
1257
|
-
payload = payload | {
|
1258
|
-
"offPeakPowerInfo": {
|
1259
|
-
"offPeakPowerTime1": {
|
1260
|
-
"endtime": {
|
1261
|
-
"timeSection": (
|
1262
|
-
1 if options.off_peak_end_time >= dt.time(12, 0) else 0
|
1263
|
-
),
|
1264
|
-
"time": options.off_peak_end_time.strftime("%I%M"),
|
1265
|
-
},
|
1266
|
-
"starttime": {
|
1267
|
-
"timeSection": (
|
1268
|
-
1 if options.off_peak_start_time >= dt.time(12, 0) else 0
|
1269
|
-
),
|
1270
|
-
"time": options.off_peak_start_time.strftime("%I%M"),
|
1271
|
-
},
|
1272
|
-
},
|
1273
|
-
"offPeakPowerFlag": 2 if options.off_peak_charge_only_enabled else 1,
|
1274
|
-
},
|
1275
|
-
"reservFlag": 1 if options.charging_enabled else 0,
|
1276
|
-
}
|
1277
|
-
|
1278
|
-
_LOGGER.debug(f"{DOMAIN} - Schedule Charging and Climate Request: {payload}")
|
1279
|
-
response = requests.post(
|
1280
|
-
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
1281
|
-
).json()
|
1282
|
-
_LOGGER.debug(f"{DOMAIN} - Schedule Charging and Climate Response: {response}")
|
1283
|
-
_check_response_for_errors(response)
|
1284
|
-
token.device_id = self._get_device_id(self._get_stamp())
|
1285
|
-
return response["msgId"]
|
1286
|
-
|
1287
1169
|
def valet_mode_action(
|
1288
1170
|
self, token: Token, vehicle: Vehicle, action: VALET_MODE_ACTION
|
1289
1171
|
) -> str:
|
@@ -1549,63 +1431,3 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1549
1431
|
dt.datetime.now().timestamp() + response["expiresTime"]
|
1550
1432
|
)
|
1551
1433
|
return control_token, control_token_expire_at
|
1552
|
-
|
1553
|
-
def check_action_status(
|
1554
|
-
self,
|
1555
|
-
token: Token,
|
1556
|
-
vehicle: Vehicle,
|
1557
|
-
action_id: str,
|
1558
|
-
synchronous: bool = False,
|
1559
|
-
timeout: int = 0,
|
1560
|
-
) -> OrderStatus:
|
1561
|
-
url = self.SPA_API_URL + "notifications/" + vehicle.id + "/records"
|
1562
|
-
|
1563
|
-
if synchronous:
|
1564
|
-
if timeout < 1:
|
1565
|
-
raise APIError("Timeout must be 1 or higher")
|
1566
|
-
|
1567
|
-
end_time = dt.datetime.now() + dt.timedelta(seconds=timeout)
|
1568
|
-
while end_time > dt.datetime.now():
|
1569
|
-
# recursive call with Synchronous set to False
|
1570
|
-
state = self.check_action_status(
|
1571
|
-
token, vehicle, action_id, synchronous=False
|
1572
|
-
)
|
1573
|
-
if state == OrderStatus.PENDING:
|
1574
|
-
# state pending: recheck regularly
|
1575
|
-
# (until we get a final state or exceed the timeout)
|
1576
|
-
sleep(5)
|
1577
|
-
else:
|
1578
|
-
# any other state is final
|
1579
|
-
return state
|
1580
|
-
|
1581
|
-
# if we exit the loop after the set timeout, return a Timeout state
|
1582
|
-
return OrderStatus.TIMEOUT
|
1583
|
-
|
1584
|
-
else:
|
1585
|
-
response = requests.get(
|
1586
|
-
url,
|
1587
|
-
headers=self._get_authenticated_headers(
|
1588
|
-
token, vehicle.ccu_ccs2_protocol_support
|
1589
|
-
),
|
1590
|
-
).json()
|
1591
|
-
_LOGGER.debug(f"{DOMAIN} - Check last action status Response: {response}")
|
1592
|
-
_check_response_for_errors(response)
|
1593
|
-
|
1594
|
-
for action in response["resMsg"]:
|
1595
|
-
if action["recordId"] == action_id:
|
1596
|
-
if action["result"] == "success":
|
1597
|
-
return OrderStatus.SUCCESS
|
1598
|
-
elif action["result"] == "fail":
|
1599
|
-
return OrderStatus.FAILED
|
1600
|
-
elif action["result"] == "non-response":
|
1601
|
-
return OrderStatus.TIMEOUT
|
1602
|
-
elif action["result"] is None:
|
1603
|
-
_LOGGER.info(
|
1604
|
-
"Action status not set yet by server - try again in a few seconds" # noqa
|
1605
|
-
)
|
1606
|
-
return OrderStatus.PENDING
|
1607
|
-
|
1608
|
-
# if iterate the whole notifications list and
|
1609
|
-
# can't find the action, raise an exception
|
1610
|
-
# Old code: raise APIError(f"No action found with ID {action_id}")
|
1611
|
-
return OrderStatus.UNKNOWN
|
@@ -25,7 +25,7 @@ from .const import (
|
|
25
25
|
DISTANCE_UNITS,
|
26
26
|
DOMAIN,
|
27
27
|
LOGIN_TOKEN_LIFETIME,
|
28
|
-
|
28
|
+
ORDER_STATUS,
|
29
29
|
TEMPERATURE_UNITS,
|
30
30
|
VEHICLE_LOCK_ACTION,
|
31
31
|
)
|
@@ -595,7 +595,7 @@ class KiaUvoApiUSA(ApiImpl):
|
|
595
595
|
action_id: str,
|
596
596
|
synchronous: bool = False,
|
597
597
|
timeout: int = 0,
|
598
|
-
) ->
|
598
|
+
) -> ORDER_STATUS:
|
599
599
|
url = self.API_URL + "cmm/gts"
|
600
600
|
body = {"xid": action_id}
|
601
601
|
response = self.post_request_with_logging_and_active_session(
|
@@ -36,7 +36,7 @@ from .const import (
|
|
36
36
|
REGIONS,
|
37
37
|
VEHICLE_LOCK_ACTION,
|
38
38
|
CHARGE_PORT_ACTION,
|
39
|
-
|
39
|
+
ORDER_STATUS,
|
40
40
|
VALET_MODE_ACTION,
|
41
41
|
)
|
42
42
|
|
@@ -206,7 +206,7 @@ class VehicleManager:
|
|
206
206
|
action_id: str,
|
207
207
|
synchronous: bool = False,
|
208
208
|
timeout: int = 120,
|
209
|
-
) ->
|
209
|
+
) -> ORDER_STATUS:
|
210
210
|
"""
|
211
211
|
Check for the status of a sent action/command.
|
212
212
|
|
hyundai_kia_connect_api/const.py
CHANGED
{hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyundai_kia_connect_api
|
3
|
-
Version: 3.34.
|
3
|
+
Version: 3.34.4
|
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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
hyundai_kia_connect_api/ApiImpl.py,sha256=UeG2FH4KCdU5LvGp5Ks793vrWbwBx8MN_DedbVRRouM,9612
|
2
|
+
hyundai_kia_connect_api/ApiImplType1.py,sha256=kdCY5GBwRJ2dRnu2CXcEzc48XbXw2Q7UOnflyEcSR3o,26919
|
3
|
+
hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
|
4
|
+
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=gvywTkeZRiL0vv_mSqZefttFK44lHmY2kFDVv31gx70,41929
|
5
|
+
hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=Y2xWIYUuiilk3FXq1ZdHQ0DsFZA_8b6AIT32l595leg,32521
|
6
|
+
hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=WP-rRI3wZmjuLYZmPXeOSk2NNNc6UhTrpOMuYMG6-iE,47043
|
7
|
+
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=xOqwFwm2V0Uc0c6G6Rlps3vtfjKsLaGAsnDQW09FQWU,57568
|
8
|
+
hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=bOG3ugG_O1g5cL3E_b4F2McXeZYJVzfBpqK_kaYgM9E,30550
|
9
|
+
hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
|
10
|
+
hyundai_kia_connect_api/Vehicle.py,sha256=hZT0wU7-mMi85bgqNHMu6CyhQQ5h-Jfmoc1ce2uPhYM,18867
|
11
|
+
hyundai_kia_connect_api/VehicleManager.py,sha256=nnHsTy49bf5nRhEC9EXFnnfx6M39JSaM2TxKK9vosbY,11733
|
12
|
+
hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
|
13
|
+
hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn-rYEjI,19730
|
14
|
+
hyundai_kia_connect_api/const.py,sha256=gFAhj9-YgrJNd7ZjYr4Qu1Yf4v-RhmyON1MJDN0eR90,2281
|
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.34.4.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
|
18
|
+
hyundai_kia_connect_api-3.34.4.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
|
19
|
+
hyundai_kia_connect_api-3.34.4.dist-info/METADATA,sha256=pb1Ky_N9KuTI69ql4vSm0-n17J2K2fcwc44PQ0b7tYI,7142
|
20
|
+
hyundai_kia_connect_api-3.34.4.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
21
|
+
hyundai_kia_connect_api-3.34.4.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
|
22
|
+
hyundai_kia_connect_api-3.34.4.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
|
23
|
+
hyundai_kia_connect_api-3.34.4.dist-info/RECORD,,
|
@@ -1,23 +0,0 @@
|
|
1
|
-
hyundai_kia_connect_api/ApiImpl.py,sha256=smtAOUzjmO3ci2LHoNiEmTe2UR1f0SqmVUQiweZ6je4,9610
|
2
|
-
hyundai_kia_connect_api/ApiImplType1.py,sha256=dlWw_HW0eLwl3Tj83llckMWxFk96QGShwXlA1iknCqY,19730
|
3
|
-
hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=FGYyrS3dSq8Plfu8DQMwVG1LM3nmRv8Y4vrN7wZ4oVY,36988
|
4
|
-
hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=hsm3PYQho9oT_TpPl7XzgcIPQjqcUL9TBv9R6ftvFiI,44267
|
5
|
-
hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=XBya0yHZ2MC3TBVQLSc6N-SzmGt_s3l4nGVyNgmjl9Q,32514
|
6
|
-
hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=cwIPZ0dU6HolKdooUQeQKlLAic6YU8dQmNs0VQDBgpQ,47035
|
7
|
-
hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=UB8JwYyRLxxmUmCkvFHt1NCiEcwfW3ZYy-r3WKOCy7M,64773
|
8
|
-
hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=8DP7iOORHtU98LipcAYEPdtJvubBlUP2-jlDxAhTDhQ,30548
|
9
|
-
hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
|
10
|
-
hyundai_kia_connect_api/Vehicle.py,sha256=hZT0wU7-mMi85bgqNHMu6CyhQQ5h-Jfmoc1ce2uPhYM,18867
|
11
|
-
hyundai_kia_connect_api/VehicleManager.py,sha256=JQLh9Tq1wIRz_CdrqiQAQBLMv1DTO_yNASIWWqZWksg,11731
|
12
|
-
hyundai_kia_connect_api/__init__.py,sha256=IkyVeIMbcFJZgLaiiNnUVA1Ferxvrm1bXHKVg01cxvc,319
|
13
|
-
hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn-rYEjI,19730
|
14
|
-
hyundai_kia_connect_api/const.py,sha256=dXEh-lpthH8000nUXFoRZpQXkTxVHDAgDe_KqnSZhZw,2280
|
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.34.2.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
|
18
|
-
hyundai_kia_connect_api-3.34.2.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
|
19
|
-
hyundai_kia_connect_api-3.34.2.dist-info/METADATA,sha256=r4pHCHt9lHQRgYymUUkf_FVkxUFmC-YyMB4S67MUbjQ,7142
|
20
|
-
hyundai_kia_connect_api-3.34.2.dist-info/WHEEL,sha256=MAQBAzGbXNI3bUmkDsiV_duv8i-gcdnLzw7cfUFwqhU,109
|
21
|
-
hyundai_kia_connect_api-3.34.2.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
|
22
|
-
hyundai_kia_connect_api-3.34.2.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
|
23
|
-
hyundai_kia_connect_api-3.34.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hyundai_kia_connect_api-3.34.2.dist-info → hyundai_kia_connect_api-3.34.4.dist-info}/top_level.txt
RENAMED
File without changes
|