hyundai-kia-connect-api 3.35.12__py2.py3-none-any.whl → 3.37.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.
- hyundai_kia_connect_api/ApiImplType1.py +126 -0
- hyundai_kia_connect_api/KiaUvoApiAU.py +0 -98
- hyundai_kia_connect_api/KiaUvoApiEU.py +0 -107
- hyundai_kia_connect_api/KiaUvoApiIN.py +861 -0
- hyundai_kia_connect_api/VehicleManager.py +4 -0
- hyundai_kia_connect_api/const.py +2 -0
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/METADATA +1 -1
- hyundai_kia_connect_api-3.37.0.dist-info/RECORD +24 -0
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/WHEEL +1 -1
- hyundai_kia_connect_api-3.35.12.dist-info/RECORD +0 -23
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/entry_points.txt +0 -0
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/licenses/LICENSE +0 -0
- {hyundai_kia_connect_api-3.35.12.dist-info → hyundai_kia_connect_api-3.37.0.dist-info}/top_level.txt +0 -0
@@ -3,6 +3,7 @@
|
|
3
3
|
import datetime as dt
|
4
4
|
import requests
|
5
5
|
import logging
|
6
|
+
import math
|
6
7
|
from typing import Optional
|
7
8
|
from datetime import timedelta, timezone
|
8
9
|
|
@@ -14,6 +15,7 @@ from .ApiImpl import (
|
|
14
15
|
ApiImpl,
|
15
16
|
ScheduleChargingClimateRequestOptions,
|
16
17
|
ClimateRequestOptions,
|
18
|
+
WindowRequestOptions,
|
17
19
|
)
|
18
20
|
from .Token import Token
|
19
21
|
from .Vehicle import Vehicle
|
@@ -94,6 +96,54 @@ class ApiImplType1(ApiImpl):
|
|
94
96
|
def __init__(self) -> None:
|
95
97
|
"""Initialize."""
|
96
98
|
|
99
|
+
def get_vehicles(self, token: Token) -> list[Vehicle]:
|
100
|
+
url = self.SPA_API_URL + "vehicles"
|
101
|
+
response = requests.get(
|
102
|
+
url,
|
103
|
+
headers=self._get_authenticated_headers(token),
|
104
|
+
).json()
|
105
|
+
_LOGGER.debug(f"{DOMAIN} - Get Vehicles Response: {response}")
|
106
|
+
_check_response_for_errors(response)
|
107
|
+
result = []
|
108
|
+
for entry in response["resMsg"]["vehicles"]:
|
109
|
+
entry_engine_type = None
|
110
|
+
if entry["type"] == "GN":
|
111
|
+
entry_engine_type = ENGINE_TYPES.ICE
|
112
|
+
elif entry["type"] == "EV":
|
113
|
+
entry_engine_type = ENGINE_TYPES.EV
|
114
|
+
elif entry["type"] == "PHEV":
|
115
|
+
entry_engine_type = ENGINE_TYPES.PHEV
|
116
|
+
elif entry["type"] == "HV":
|
117
|
+
entry_engine_type = ENGINE_TYPES.HEV
|
118
|
+
elif entry["type"] == "PE":
|
119
|
+
entry_engine_type = ENGINE_TYPES.PHEV
|
120
|
+
vehicle: Vehicle = Vehicle(
|
121
|
+
id=entry["vehicleId"],
|
122
|
+
name=entry["nickname"],
|
123
|
+
model=entry["vehicleName"],
|
124
|
+
registration_date=entry["regDate"],
|
125
|
+
VIN=entry["vin"],
|
126
|
+
timezone=self.data_timezone,
|
127
|
+
engine_type=entry_engine_type,
|
128
|
+
ccu_ccs2_protocol_support=entry["ccuCCS2ProtocolSupport"],
|
129
|
+
)
|
130
|
+
result.append(vehicle)
|
131
|
+
return result
|
132
|
+
|
133
|
+
def _get_time_from_string(self, value, timesection) -> dt.datetime.time:
|
134
|
+
if value is not None:
|
135
|
+
lastTwo = int(value[-2:])
|
136
|
+
if lastTwo > 60:
|
137
|
+
value = int(value) + 40
|
138
|
+
if int(value) > 1260:
|
139
|
+
value = dt.datetime.strptime(str(value), "%H%M").time()
|
140
|
+
else:
|
141
|
+
d = dt.datetime.strptime(str(value), "%I%M")
|
142
|
+
if timesection > 0:
|
143
|
+
d += dt.timedelta(hours=12)
|
144
|
+
value = d.time()
|
145
|
+
return value
|
146
|
+
|
97
147
|
def _get_authenticated_headers(
|
98
148
|
self, token: Token, ccs2_support: Optional[int] = None
|
99
149
|
) -> dict:
|
@@ -848,3 +898,79 @@ class ApiImplType1(ApiImpl):
|
|
848
898
|
_check_response_for_errors(response)
|
849
899
|
token.device_id = self._get_device_id(self._get_stamp())
|
850
900
|
return response["msgId"]
|
901
|
+
|
902
|
+
def start_hazard_lights(self, token: Token, vehicle: Vehicle) -> str:
|
903
|
+
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/light"
|
904
|
+
|
905
|
+
payload = {"command": "on"}
|
906
|
+
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights Request: {payload}")
|
907
|
+
response = requests.post(
|
908
|
+
url,
|
909
|
+
json=payload,
|
910
|
+
headers=self._get_control_headers(token, vehicle),
|
911
|
+
).json()
|
912
|
+
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights Response: {response}")
|
913
|
+
_check_response_for_errors(response)
|
914
|
+
token.device_id = self._get_device_id(self._get_stamp())
|
915
|
+
return response["msgId"]
|
916
|
+
|
917
|
+
def start_hazard_lights_and_horn(self, token: Token, vehicle: Vehicle) -> str:
|
918
|
+
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/hornlight"
|
919
|
+
|
920
|
+
payload = {"command": "on"}
|
921
|
+
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights and Horn Request: {payload}")
|
922
|
+
response = requests.post(
|
923
|
+
url,
|
924
|
+
json=payload,
|
925
|
+
headers=self._get_control_headers(token, vehicle),
|
926
|
+
).json()
|
927
|
+
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights and Horn Response: {response}")
|
928
|
+
_check_response_for_errors(response)
|
929
|
+
token.device_id = self._get_device_id(self._get_stamp())
|
930
|
+
return response["msgId"]
|
931
|
+
|
932
|
+
def set_windows_state(
|
933
|
+
self, token: Token, vehicle: Vehicle, options: WindowRequestOptions
|
934
|
+
) -> str:
|
935
|
+
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/control/windowcurtain"
|
936
|
+
|
937
|
+
payload = {
|
938
|
+
"backLeft": options.back_left,
|
939
|
+
"backRight": options.back_right,
|
940
|
+
"frontLeft": options.front_left,
|
941
|
+
"frontRight": options.front_right,
|
942
|
+
}
|
943
|
+
_LOGGER.debug(f"{DOMAIN} - Window State Action Request: {payload}")
|
944
|
+
response = requests.post(
|
945
|
+
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
946
|
+
).json()
|
947
|
+
_LOGGER.debug(f"{DOMAIN} - Window State Action Response: {response}")
|
948
|
+
_check_response_for_errors(response)
|
949
|
+
return response["msgId"]
|
950
|
+
|
951
|
+
def _get_control_token(self, token: Token) -> Token:
|
952
|
+
url = self.USER_API_URL + "pin?token="
|
953
|
+
headers = {
|
954
|
+
"Authorization": token.access_token,
|
955
|
+
"Content-type": "application/json",
|
956
|
+
"Host": self.BASE_URL,
|
957
|
+
"Accept-Encoding": "gzip",
|
958
|
+
"User-Agent": USER_AGENT_OK_HTTP,
|
959
|
+
}
|
960
|
+
|
961
|
+
data = {"deviceId": token.device_id, "pin": token.pin}
|
962
|
+
response = requests.put(url, json=data, headers=headers)
|
963
|
+
response = response.json()
|
964
|
+
_LOGGER.debug(f"{DOMAIN} - Get Control Token Response {response}")
|
965
|
+
control_token = "Bearer " + response["controlToken"]
|
966
|
+
control_token_expire_at = math.floor(
|
967
|
+
dt.datetime.now().timestamp() + response["expiresTime"]
|
968
|
+
)
|
969
|
+
return control_token, control_token_expire_at
|
970
|
+
|
971
|
+
def _set_session_language(self, cookies) -> None:
|
972
|
+
# Set Language for Session #
|
973
|
+
url = self.USER_API_URL + "language"
|
974
|
+
headers = {"Content-type": "application/json"}
|
975
|
+
payload = {"lang": self.LANGUAGE}
|
976
|
+
_ = requests.post(url, json=payload, headers=headers, cookies=cookies)
|
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
import base64
|
6
6
|
import datetime as dt
|
7
|
-
import math
|
8
7
|
import logging
|
9
8
|
import random
|
10
9
|
import uuid
|
@@ -14,9 +13,6 @@ import pytz
|
|
14
13
|
import requests
|
15
14
|
from dateutil import tz
|
16
15
|
|
17
|
-
from .ApiImpl import (
|
18
|
-
WindowRequestOptions,
|
19
|
-
)
|
20
16
|
from .ApiImplType1 import ApiImplType1
|
21
17
|
from .Token import Token
|
22
18
|
from .Vehicle import (
|
@@ -107,51 +103,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
107
103
|
valid_until=valid_until,
|
108
104
|
)
|
109
105
|
|
110
|
-
def get_vehicles(self, token: Token) -> list[Vehicle]:
|
111
|
-
url = self.SPA_API_URL + "vehicles"
|
112
|
-
response = requests.get(
|
113
|
-
url, headers=self._get_authenticated_headers(token)
|
114
|
-
).json()
|
115
|
-
_LOGGER.debug(f"{DOMAIN} - Get Vehicles Response: {response}")
|
116
|
-
_check_response_for_errors(response)
|
117
|
-
result = []
|
118
|
-
for entry in response["resMsg"]["vehicles"]:
|
119
|
-
entry_engine_type = None
|
120
|
-
if entry["type"] == "GN":
|
121
|
-
entry_engine_type = ENGINE_TYPES.ICE
|
122
|
-
elif entry["type"] == "EV":
|
123
|
-
entry_engine_type = ENGINE_TYPES.EV
|
124
|
-
elif entry["type"] == "PHEV":
|
125
|
-
entry_engine_type = ENGINE_TYPES.PHEV
|
126
|
-
elif entry["type"] == "HV":
|
127
|
-
entry_engine_type = ENGINE_TYPES.HEV
|
128
|
-
vehicle: Vehicle = Vehicle(
|
129
|
-
id=entry["vehicleId"],
|
130
|
-
name=entry["nickname"],
|
131
|
-
model=entry["vehicleName"],
|
132
|
-
registration_date=entry["regDate"],
|
133
|
-
VIN=entry["vin"],
|
134
|
-
timezone=self.data_timezone,
|
135
|
-
engine_type=entry_engine_type,
|
136
|
-
ccu_ccs2_protocol_support=entry["ccuCCS2ProtocolSupport"],
|
137
|
-
)
|
138
|
-
result.append(vehicle)
|
139
|
-
return result
|
140
|
-
|
141
|
-
def _get_time_from_string(self, value, timesection) -> dt.datetime.time:
|
142
|
-
if value is not None:
|
143
|
-
lastTwo = int(value[-2:])
|
144
|
-
if lastTwo > 60:
|
145
|
-
value = int(value) + 40
|
146
|
-
if int(value) > 1260:
|
147
|
-
value = dt.datetime.strptime(str(value), "%H%M").time()
|
148
|
-
else:
|
149
|
-
d = dt.datetime.strptime(str(value), "%I%M")
|
150
|
-
if timesection > 0:
|
151
|
-
d += dt.timedelta(hours=12)
|
152
|
-
value = d.time()
|
153
|
-
return value
|
154
|
-
|
155
106
|
def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> None:
|
156
107
|
url = self.SPA_API_URL + "vehicles/" + vehicle.id
|
157
108
|
is_ccs2 = vehicle.ccu_ccs2_protocol_support != 0
|
@@ -625,25 +576,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
625
576
|
mapped_response["vehicleStatus"] = response["resMsg"]
|
626
577
|
return mapped_response
|
627
578
|
|
628
|
-
def set_windows_state(
|
629
|
-
self, token: Token, vehicle: Vehicle, options: WindowRequestOptions
|
630
|
-
) -> str:
|
631
|
-
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/control/windowcurtain"
|
632
|
-
|
633
|
-
payload = {
|
634
|
-
"backLeft": options.back_left,
|
635
|
-
"backRight": options.back_right,
|
636
|
-
"frontLeft": options.front_left,
|
637
|
-
"frontRight": options.front_right,
|
638
|
-
}
|
639
|
-
_LOGGER.debug(f"{DOMAIN} - Window State Action Request: {payload}")
|
640
|
-
response = requests.post(
|
641
|
-
url, json=payload, headers=self._get_control_headers(token, vehicle)
|
642
|
-
).json()
|
643
|
-
_LOGGER.debug(f"{DOMAIN} - Window State Action Response: {response}")
|
644
|
-
_check_response_for_errors(response)
|
645
|
-
return response["msgId"]
|
646
|
-
|
647
579
|
def charge_port_action(
|
648
580
|
self, token: Token, vehicle: Vehicle, action: CHARGE_PORT_ACTION
|
649
581
|
) -> str:
|
@@ -864,7 +796,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
864
796
|
10**80
|
865
797
|
)
|
866
798
|
registration_id = my_hex[:64]
|
867
|
-
# provider_device_id = "59af09e554a9442ab8589c9500d04d2e"
|
868
799
|
url = self.SPA_API_URL + "notifications/register"
|
869
800
|
payload = {
|
870
801
|
# "providerDeviceId": provider_device_id,
|
@@ -910,14 +841,6 @@ class KiaUvoApiAU(ApiImplType1):
|
|
910
841
|
_ = session.get(url)
|
911
842
|
_LOGGER.debug(f"{DOMAIN} - Get cookies response: {session.cookies.get_dict()}")
|
912
843
|
return session.cookies.get_dict()
|
913
|
-
# return session
|
914
|
-
|
915
|
-
def _set_session_language(self, cookies) -> None:
|
916
|
-
# Set Language for Session #
|
917
|
-
url = self.USER_API_URL
|
918
|
-
headers = {"Content-type": "application/json"}
|
919
|
-
payload = {"lang": "en"}
|
920
|
-
_ = requests.post(url, json=payload, headers=headers, cookies=cookies)
|
921
844
|
|
922
845
|
def _get_authorization_code_with_redirect_url(
|
923
846
|
self, username, password, cookies
|
@@ -978,24 +901,3 @@ class KiaUvoApiAU(ApiImplType1):
|
|
978
901
|
token_type = response["token_type"]
|
979
902
|
refresh_token = token_type + " " + response["access_token"]
|
980
903
|
return token_type, refresh_token
|
981
|
-
|
982
|
-
def _get_control_token(self, token: Token) -> Token:
|
983
|
-
url = self.USER_API_URL + "pin?token="
|
984
|
-
headers = {
|
985
|
-
"Authorization": token.access_token,
|
986
|
-
"Content-type": "application/json",
|
987
|
-
"Host": self.BASE_URL,
|
988
|
-
"Accept-Encoding": "gzip",
|
989
|
-
"User-Agent": USER_AGENT_OK_HTTP,
|
990
|
-
}
|
991
|
-
|
992
|
-
data = {"deviceId": token.device_id, "pin": token.pin}
|
993
|
-
_LOGGER.debug(f"{DOMAIN} - Get Control Token Data: {data}")
|
994
|
-
response = requests.put(url, json=data, headers=headers)
|
995
|
-
response = response.json()
|
996
|
-
_LOGGER.debug(f"{DOMAIN} - Get Control Token Response {response}")
|
997
|
-
control_token = "Bearer " + response["controlToken"]
|
998
|
-
control_token_expire_at = math.floor(
|
999
|
-
dt.datetime.now().timestamp() + response["expiresTime"]
|
1000
|
-
)
|
1001
|
-
return control_token, control_token_expire_at
|
@@ -7,7 +7,6 @@ import random
|
|
7
7
|
import datetime as dt
|
8
8
|
import logging
|
9
9
|
import uuid
|
10
|
-
import math
|
11
10
|
from urllib.parse import parse_qs, urlparse
|
12
11
|
|
13
12
|
import pytz
|
@@ -209,54 +208,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
209
208
|
valid_until=valid_until,
|
210
209
|
)
|
211
210
|
|
212
|
-
def get_vehicles(self, token: Token) -> list[Vehicle]:
|
213
|
-
url = self.SPA_API_URL + "vehicles"
|
214
|
-
response = requests.get(
|
215
|
-
url,
|
216
|
-
headers=self._get_authenticated_headers(token),
|
217
|
-
).json()
|
218
|
-
_LOGGER.debug(f"{DOMAIN} - Get Vehicles Response: {response}")
|
219
|
-
_check_response_for_errors(response)
|
220
|
-
result = []
|
221
|
-
for entry in response["resMsg"]["vehicles"]:
|
222
|
-
entry_engine_type = None
|
223
|
-
if entry["type"] == "GN":
|
224
|
-
entry_engine_type = ENGINE_TYPES.ICE
|
225
|
-
elif entry["type"] == "EV":
|
226
|
-
entry_engine_type = ENGINE_TYPES.EV
|
227
|
-
elif entry["type"] == "PHEV":
|
228
|
-
entry_engine_type = ENGINE_TYPES.PHEV
|
229
|
-
elif entry["type"] == "HV":
|
230
|
-
entry_engine_type = ENGINE_TYPES.HEV
|
231
|
-
elif entry["type"] == "PE":
|
232
|
-
entry_engine_type = ENGINE_TYPES.PHEV
|
233
|
-
vehicle: Vehicle = Vehicle(
|
234
|
-
id=entry["vehicleId"],
|
235
|
-
name=entry["nickname"],
|
236
|
-
model=entry["vehicleName"],
|
237
|
-
registration_date=entry["regDate"],
|
238
|
-
VIN=entry["vin"],
|
239
|
-
timezone=self.data_timezone,
|
240
|
-
engine_type=entry_engine_type,
|
241
|
-
ccu_ccs2_protocol_support=entry["ccuCCS2ProtocolSupport"],
|
242
|
-
)
|
243
|
-
result.append(vehicle)
|
244
|
-
return result
|
245
|
-
|
246
|
-
def _get_time_from_string(self, value, timesection) -> dt.datetime.time:
|
247
|
-
if value is not None:
|
248
|
-
lastTwo = int(value[-2:])
|
249
|
-
if lastTwo > 60:
|
250
|
-
value = int(value) + 40
|
251
|
-
if int(value) > 1260:
|
252
|
-
value = dt.datetime.strptime(str(value), "%H%M").time()
|
253
|
-
else:
|
254
|
-
d = dt.datetime.strptime(str(value), "%I%M")
|
255
|
-
if timesection > 0:
|
256
|
-
d += dt.timedelta(hours=12)
|
257
|
-
value = d.time()
|
258
|
-
return value
|
259
|
-
|
260
211
|
def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> None:
|
261
212
|
url = self.SPA_API_URL + "vehicles/" + vehicle.id
|
262
213
|
is_ccs2 = vehicle.ccu_ccs2_protocol_support != 0
|
@@ -851,36 +802,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
851
802
|
token.device_id = self._get_device_id(self._get_stamp())
|
852
803
|
return response["msgId"]
|
853
804
|
|
854
|
-
def start_hazard_lights(self, token: Token, vehicle: Vehicle) -> str:
|
855
|
-
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/light"
|
856
|
-
|
857
|
-
payload = {"command": "on"}
|
858
|
-
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights Request: {payload}")
|
859
|
-
response = requests.post(
|
860
|
-
url,
|
861
|
-
json=payload,
|
862
|
-
headers=self._get_control_headers(token, vehicle),
|
863
|
-
).json()
|
864
|
-
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights Response: {response}")
|
865
|
-
_check_response_for_errors(response)
|
866
|
-
token.device_id = self._get_device_id(self._get_stamp())
|
867
|
-
return response["msgId"]
|
868
|
-
|
869
|
-
def start_hazard_lights_and_horn(self, token: Token, vehicle: Vehicle) -> str:
|
870
|
-
url = self.SPA_API_URL_V2 + "vehicles/" + vehicle.id + "/ccs2/control/hornlight"
|
871
|
-
|
872
|
-
payload = {"command": "on"}
|
873
|
-
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights and Horn Request: {payload}")
|
874
|
-
response = requests.post(
|
875
|
-
url,
|
876
|
-
json=payload,
|
877
|
-
headers=self._get_control_headers(token, vehicle),
|
878
|
-
).json()
|
879
|
-
_LOGGER.debug(f"{DOMAIN} - Start Hazard Lights and Horn Response: {response}")
|
880
|
-
_check_response_for_errors(response)
|
881
|
-
token.device_id = self._get_device_id(self._get_stamp())
|
882
|
-
return response["msgId"]
|
883
|
-
|
884
805
|
def _get_charge_limits(self, token: Token, vehicle: Vehicle) -> dict:
|
885
806
|
# Not currently used as value is in the general get.
|
886
807
|
# Most likely this forces the car the update it.
|
@@ -1163,13 +1084,6 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1163
1084
|
return session.cookies.get_dict()
|
1164
1085
|
# return session
|
1165
1086
|
|
1166
|
-
def _set_session_language(self, cookies) -> None:
|
1167
|
-
# Set Language for Session #
|
1168
|
-
url = self.USER_API_URL + "language"
|
1169
|
-
headers = {"Content-type": "application/json"}
|
1170
|
-
payload = {"lang": self.LANGUAGE}
|
1171
|
-
_ = requests.post(url, json=payload, headers=headers, cookies=cookies)
|
1172
|
-
|
1173
1087
|
def _get_authorization_code_with_redirect_url(
|
1174
1088
|
self, username, password, cookies
|
1175
1089
|
) -> str:
|
@@ -1331,24 +1245,3 @@ class KiaUvoApiEU(ApiImplType1):
|
|
1331
1245
|
token_type = response["token_type"]
|
1332
1246
|
refresh_token = token_type + " " + response["access_token"]
|
1333
1247
|
return token_type, refresh_token
|
1334
|
-
|
1335
|
-
def _get_control_token(self, token: Token) -> Token:
|
1336
|
-
url = self.USER_API_URL + "pin?token="
|
1337
|
-
headers = {
|
1338
|
-
"Authorization": token.access_token,
|
1339
|
-
"Content-type": "application/json",
|
1340
|
-
"Host": self.BASE_URL,
|
1341
|
-
"Accept-Encoding": "gzip",
|
1342
|
-
"User-Agent": USER_AGENT_OK_HTTP,
|
1343
|
-
}
|
1344
|
-
|
1345
|
-
data = {"deviceId": token.device_id, "pin": token.pin}
|
1346
|
-
_LOGGER.debug(f"{DOMAIN} - Get Control Token Data: {data}")
|
1347
|
-
response = requests.put(url, json=data, headers=headers)
|
1348
|
-
response = response.json()
|
1349
|
-
_LOGGER.debug(f"{DOMAIN} - Get Control Token Response {response}")
|
1350
|
-
control_token = "Bearer " + response["controlToken"]
|
1351
|
-
control_token_expire_at = math.floor(
|
1352
|
-
dt.datetime.now().timestamp() + response["expiresTime"]
|
1353
|
-
)
|
1354
|
-
return control_token, control_token_expire_at
|