pyezvizapi 1.0.0.3__py3-none-any.whl → 1.0.0.4__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.
Potentially problematic release.
This version of pyezvizapi might be problematic. Click here for more details.
- pyezvizapi/api_endpoints.py +13 -11
- pyezvizapi/client.py +135 -80
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/METADATA +1 -1
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/RECORD +9 -9
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/LICENSE +0 -0
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/LICENSE.md +0 -0
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/WHEEL +0 -0
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/entry_points.txt +0 -0
- {pyezvizapi-1.0.0.3.dist-info → pyezvizapi-1.0.0.4.dist-info}/top_level.txt +0 -0
pyezvizapi/api_endpoints.py
CHANGED
|
@@ -7,31 +7,36 @@ API_ENDPOINT_LOGIN = "/v3/users/login/v5"
|
|
|
7
7
|
API_ENDPOINT_LOGOUT = "/v3/users/logout/v2"
|
|
8
8
|
API_ENDPOINT_REFRESH_SESSION_ID = "/v3/apigateway/login"
|
|
9
9
|
API_ENDPOINT_SERVER_INFO = "/v3/configurations/system/info"
|
|
10
|
+
|
|
10
11
|
API_ENDPOINT_USER_ID = "/v3/userdevices/v1/token"
|
|
11
12
|
API_ENDPOINT_GROUP_DEFENCE_MODE = "/v3/userdevices/v1/group/defenceMode"
|
|
13
|
+
API_ENDPOINT_PAGELIST = "/v3/userdevices/v1/resources/pagelist"
|
|
14
|
+
API_ENDPOINT_SWITCH_DEFENCE_MODE = "/v3/userdevices/v1/group/switchDefenceMode"
|
|
12
15
|
|
|
13
16
|
API_ENDPOINT_PANORAMIC_DEVICES_OPERATION = "/v3/panoramicDevices/operation"
|
|
14
17
|
API_ENDPOINT_UPGRADE_DEVICE = "/v3/upgrades/v1/devices/"
|
|
15
18
|
API_ENDPOINT_SEND_CODE = "/v3/sms/nologin/checkcode"
|
|
19
|
+
API_ENDPOINT_UNIFIEDMSG_LIST_GET = "/v3/unifiedmsg/list"
|
|
20
|
+
API_ENDPOINT_IOT_FEATURE = "/v3/iot-feature/feature/"
|
|
21
|
+
API_ENDPOINT_CALLING_NOTIFY = "/v3/calling/"
|
|
16
22
|
|
|
17
23
|
API_ENDPOINT_ALARMINFO_GET = "/v3/alarms/v2/advanced"
|
|
18
|
-
API_ENDPOINT_UNIFIEDMSG_LIST_GET = "/v3/unifiedmsg/list"
|
|
19
24
|
API_ENDPOINT_V3_ALARMS = "/v3/alarms/"
|
|
20
|
-
API_ENDPOINT_SET_LUMINANCE = "/v3/alarms/device/alarmLight"
|
|
25
|
+
API_ENDPOINT_SET_LUMINANCE = "/v3/alarms/device/alarmLight/"
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
API_ENDPOINT_DEVCONFIG_BY_KEY = "/v3/devconfig/v1/keyValue/"
|
|
28
|
+
API_ENDPOINT_CAM_AUTH_CODE = "/v3/devconfig/authcode/query/"
|
|
24
29
|
|
|
25
30
|
API_ENDPOINT_DETECTION_SENSIBILITY = "/api/device/configAlgorithm"
|
|
26
31
|
API_ENDPOINT_DETECTION_SENSIBILITY_GET = "/api/device/queryAlgorithmConfig"
|
|
27
32
|
API_ENDPOINT_SET_DEFENCE_SCHEDULE = "/api/device/defence/plan2"
|
|
28
33
|
API_ENDPOINT_CAM_ENCRYPTKEY = "/api/device/query/encryptkey"
|
|
29
|
-
|
|
34
|
+
API_ENDPOINT_OFFLINE_NOTIFY = "/api/device/notify/switch"
|
|
30
35
|
API_ENDPOINT_CANCEL_ALARM = "/api/device/cancelAlarm"
|
|
31
36
|
API_ENDPOINT_DEVICE_SYS_OPERATION = "/api/device/v2/sysOper/"
|
|
32
37
|
API_ENDPOINT_DEVICE_STORAGE_STATUS = "/api/device/queryStorageStatus"
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
API_ENDPOINT_CREATE_PANORAMIC = "/api/panoramic/devices/pics/collect"
|
|
39
|
+
API_ENDPOINT_RETURN_PANORAMIC = "/api/panoramic/devices/pics"
|
|
35
40
|
|
|
36
41
|
# Videogo DeviceApi
|
|
37
42
|
API_ENDPOINT_DEVICES = "/v3/devices/"
|
|
@@ -42,10 +47,7 @@ API_ENDPOINT_ALARM_SOUND = "/alarm/sound"
|
|
|
42
47
|
API_ENDPOINT_SWITCH_SOUND_ALARM = "/sendAlarm"
|
|
43
48
|
API_ENDPOINT_DO_NOT_DISTURB = "/nodisturb"
|
|
44
49
|
API_ENDPOINT_VIDEO_ENCRYPT = "encryptedInfo/risk"
|
|
45
|
-
API_ENDPOINT_CHANGE_DEFENCE_STATUS = "changeDefenceStatusReq"
|
|
46
|
-
|
|
47
|
-
API_ENDPOINT_CREATE_PANORAMIC = "/api/panoramic/devices/pics/collect"
|
|
48
|
-
API_ENDPOINT_RETURN_PANORAMIC = "/api/panoramic/devices/pics"
|
|
50
|
+
API_ENDPOINT_CHANGE_DEFENCE_STATUS = "/changeDefenceStatusReq"
|
|
49
51
|
|
|
50
52
|
# MQTT
|
|
51
53
|
API_ENDPOINT_REGISTER_MQTT = "/v1/getClientId"
|
pyezvizapi/client.py
CHANGED
|
@@ -15,6 +15,7 @@ import requests
|
|
|
15
15
|
from .api_endpoints import (
|
|
16
16
|
API_ENDPOINT_ALARM_SOUND,
|
|
17
17
|
API_ENDPOINT_ALARMINFO_GET,
|
|
18
|
+
API_ENDPOINT_CALLING_NOTIFY,
|
|
18
19
|
API_ENDPOINT_CAM_AUTH_CODE,
|
|
19
20
|
API_ENDPOINT_CAM_ENCRYPTKEY,
|
|
20
21
|
API_ENDPOINT_CANCEL_ALARM,
|
|
@@ -31,6 +32,7 @@ from .api_endpoints import (
|
|
|
31
32
|
API_ENDPOINT_IOT_FEATURE,
|
|
32
33
|
API_ENDPOINT_LOGIN,
|
|
33
34
|
API_ENDPOINT_LOGOUT,
|
|
35
|
+
API_ENDPOINT_OFFLINE_NOTIFY,
|
|
34
36
|
API_ENDPOINT_PAGELIST,
|
|
35
37
|
API_ENDPOINT_PANORAMIC_DEVICES_OPERATION,
|
|
36
38
|
API_ENDPOINT_PTZCONTROL,
|
|
@@ -123,7 +125,7 @@ class EzvizClient:
|
|
|
123
125
|
|
|
124
126
|
try:
|
|
125
127
|
req = self._session.post(
|
|
126
|
-
"https://
|
|
128
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_LOGIN}",
|
|
127
129
|
allow_redirects=False,
|
|
128
130
|
data=payload,
|
|
129
131
|
timeout=self._timeout,
|
|
@@ -193,7 +195,7 @@ class EzvizClient:
|
|
|
193
195
|
"""Send verification code."""
|
|
194
196
|
try:
|
|
195
197
|
req = self._session.post(
|
|
196
|
-
"https://
|
|
198
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_SEND_CODE}",
|
|
197
199
|
data={
|
|
198
200
|
"from": self.account,
|
|
199
201
|
"bizType": "TERMINAL_BIND",
|
|
@@ -230,7 +232,7 @@ class EzvizClient:
|
|
|
230
232
|
|
|
231
233
|
try:
|
|
232
234
|
req = self._session.get(
|
|
233
|
-
f"https://{self._token['api_url']}{API_ENDPOINT_SERVER_INFO}",
|
|
235
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_SERVER_INFO}",
|
|
234
236
|
timeout=self._timeout,
|
|
235
237
|
)
|
|
236
238
|
req.raise_for_status()
|
|
@@ -286,7 +288,7 @@ class EzvizClient:
|
|
|
286
288
|
|
|
287
289
|
try:
|
|
288
290
|
req = self._session.get(
|
|
289
|
-
"https://
|
|
291
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_PAGELIST}",
|
|
290
292
|
params=params,
|
|
291
293
|
timeout=self._timeout,
|
|
292
294
|
)
|
|
@@ -355,7 +357,7 @@ class EzvizClient:
|
|
|
355
357
|
|
|
356
358
|
try:
|
|
357
359
|
req = self._session.get(
|
|
358
|
-
"https://
|
|
360
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_ALARMINFO_GET}",
|
|
359
361
|
params=params,
|
|
360
362
|
timeout=self._timeout,
|
|
361
363
|
)
|
|
@@ -418,7 +420,7 @@ class EzvizClient:
|
|
|
418
420
|
|
|
419
421
|
try:
|
|
420
422
|
req = self._session.get(
|
|
421
|
-
"https://
|
|
423
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_UNIFIEDMSG_LIST_GET}",
|
|
422
424
|
params=params,
|
|
423
425
|
timeout=self._timeout,
|
|
424
426
|
)
|
|
@@ -570,7 +572,7 @@ class EzvizClient:
|
|
|
570
572
|
|
|
571
573
|
try:
|
|
572
574
|
req = self._session.put(
|
|
573
|
-
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}/{channel_no}
|
|
575
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}/{channel_no}{API_ENDPOINT_CHANGE_DEFENCE_STATUS}",
|
|
574
576
|
timeout=self._timeout,
|
|
575
577
|
data={
|
|
576
578
|
"type": arm_type,
|
|
@@ -771,11 +773,7 @@ class EzvizClient:
|
|
|
771
773
|
|
|
772
774
|
try:
|
|
773
775
|
req = self._session.put(
|
|
774
|
-
"https://"
|
|
775
|
-
+ self._token["api_url"]
|
|
776
|
-
+ API_ENDPOINT_UPGRADE_DEVICE
|
|
777
|
-
+ serial
|
|
778
|
-
+ "/0/upgrade",
|
|
776
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_UPGRADE_DEVICE}{serial}/0/upgrade",
|
|
779
777
|
timeout=self._timeout,
|
|
780
778
|
)
|
|
781
779
|
|
|
@@ -862,12 +860,7 @@ class EzvizClient:
|
|
|
862
860
|
|
|
863
861
|
try:
|
|
864
862
|
req = self._session.put(
|
|
865
|
-
"https://"
|
|
866
|
-
+ self._token["api_url"]
|
|
867
|
-
+ API_ENDPOINT_DEVICES
|
|
868
|
-
+ serial
|
|
869
|
-
+ "/0"
|
|
870
|
-
+ API_ENDPOINT_SWITCH_SOUND_ALARM,
|
|
863
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}/0{API_ENDPOINT_SWITCH_SOUND_ALARM}",
|
|
871
864
|
data={
|
|
872
865
|
"enable": enable,
|
|
873
866
|
},
|
|
@@ -908,7 +901,7 @@ class EzvizClient:
|
|
|
908
901
|
|
|
909
902
|
try:
|
|
910
903
|
req = self._session.get(
|
|
911
|
-
f"https://{self._token['api_url']}{API_ENDPOINT_USER_ID}",
|
|
904
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_USER_ID}",
|
|
912
905
|
timeout=self._timeout,
|
|
913
906
|
)
|
|
914
907
|
req.raise_for_status()
|
|
@@ -958,10 +951,7 @@ class EzvizClient:
|
|
|
958
951
|
|
|
959
952
|
try:
|
|
960
953
|
req = self._session.put(
|
|
961
|
-
"https://"
|
|
962
|
-
+ self._token["api_url"]
|
|
963
|
-
+ API_ENDPOINT_DEVICES
|
|
964
|
-
+ API_ENDPOINT_VIDEO_ENCRYPT,
|
|
954
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{API_ENDPOINT_VIDEO_ENCRYPT}",
|
|
965
955
|
data={
|
|
966
956
|
"deviceSerial": serial,
|
|
967
957
|
"isEncrypt": enable, # 1 = enable, 0 = disable, 2 = change password
|
|
@@ -1068,6 +1058,69 @@ class EzvizClient:
|
|
|
1068
1058
|
|
|
1069
1059
|
return True
|
|
1070
1060
|
|
|
1061
|
+
def set_offline_notification(
|
|
1062
|
+
self,
|
|
1063
|
+
serial: str,
|
|
1064
|
+
enable: int = 1,
|
|
1065
|
+
req_type: int = 1,
|
|
1066
|
+
max_retries: int = 0,
|
|
1067
|
+
) -> bool:
|
|
1068
|
+
"""Set offline notification."""
|
|
1069
|
+
if max_retries > MAX_RETRIES:
|
|
1070
|
+
raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
|
|
1071
|
+
|
|
1072
|
+
try:
|
|
1073
|
+
req = self._session.post(
|
|
1074
|
+
url=f'https://{self._token["api_url"]}{API_ENDPOINT_OFFLINE_NOTIFY}',
|
|
1075
|
+
data={
|
|
1076
|
+
"reqType": req_type,
|
|
1077
|
+
"serial": serial,
|
|
1078
|
+
"status": enable,
|
|
1079
|
+
},
|
|
1080
|
+
timeout=self._timeout,
|
|
1081
|
+
)
|
|
1082
|
+
|
|
1083
|
+
req.raise_for_status()
|
|
1084
|
+
|
|
1085
|
+
except requests.HTTPError as err:
|
|
1086
|
+
if err.response.status_code == 401:
|
|
1087
|
+
# session is wrong, need to relogin
|
|
1088
|
+
self.login()
|
|
1089
|
+
return self.set_offline_notification(
|
|
1090
|
+
serial,
|
|
1091
|
+
enable,
|
|
1092
|
+
req_type,
|
|
1093
|
+
max_retries + 1,
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1096
|
+
raise HTTPError from err
|
|
1097
|
+
|
|
1098
|
+
try:
|
|
1099
|
+
json_output = req.json()
|
|
1100
|
+
|
|
1101
|
+
except ValueError as err:
|
|
1102
|
+
raise PyEzvizError(
|
|
1103
|
+
"Impossible to decode response: "
|
|
1104
|
+
+ str(err)
|
|
1105
|
+
+ "\nResponse was: "
|
|
1106
|
+
+ str(req.text)
|
|
1107
|
+
) from err
|
|
1108
|
+
|
|
1109
|
+
if json_output["resultCode"] != "0":
|
|
1110
|
+
if json_output["resultCode"] == "-1":
|
|
1111
|
+
_LOGGER.warning(
|
|
1112
|
+
"Unable to set offline notification, camera %s is unreachable, retrying %s of %s",
|
|
1113
|
+
serial,
|
|
1114
|
+
max_retries,
|
|
1115
|
+
MAX_RETRIES,
|
|
1116
|
+
)
|
|
1117
|
+
return self.set_offline_notification(
|
|
1118
|
+
serial, enable, req_type, max_retries + 1
|
|
1119
|
+
)
|
|
1120
|
+
raise PyEzvizError(f"Could not set offline notification {json_output})")
|
|
1121
|
+
|
|
1122
|
+
return True
|
|
1123
|
+
|
|
1071
1124
|
def get_group_defence_mode(self, max_retries: int = 0) -> Any:
|
|
1072
1125
|
"""Get group arm status. The alarm arm/disarm concept on 1st page of app."""
|
|
1073
1126
|
|
|
@@ -1076,7 +1129,7 @@ class EzvizClient:
|
|
|
1076
1129
|
|
|
1077
1130
|
try:
|
|
1078
1131
|
req = self._session.get(
|
|
1079
|
-
"https://
|
|
1132
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_GROUP_DEFENCE_MODE}",
|
|
1080
1133
|
params={
|
|
1081
1134
|
"groupId": -1,
|
|
1082
1135
|
},
|
|
@@ -1119,7 +1172,7 @@ class EzvizClient:
|
|
|
1119
1172
|
|
|
1120
1173
|
try:
|
|
1121
1174
|
req = self._session.post(
|
|
1122
|
-
"https://
|
|
1175
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_CANCEL_ALARM}",
|
|
1123
1176
|
data={"subSerial": serial},
|
|
1124
1177
|
timeout=self._timeout,
|
|
1125
1178
|
)
|
|
@@ -1265,15 +1318,11 @@ class EzvizClient:
|
|
|
1265
1318
|
|
|
1266
1319
|
try:
|
|
1267
1320
|
req = self._session.put(
|
|
1268
|
-
"https://"
|
|
1269
|
-
+ self._token["api_url"]
|
|
1270
|
-
+ API_ENDPOINT_DEVICES
|
|
1271
|
-
+ serial
|
|
1272
|
-
+ API_ENDPOINT_PTZCONTROL,
|
|
1321
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}{API_ENDPOINT_PTZCONTROL}",
|
|
1273
1322
|
data={
|
|
1274
1323
|
"command": command,
|
|
1275
1324
|
"action": action,
|
|
1276
|
-
"channelNo":
|
|
1325
|
+
"channelNo": 1,
|
|
1277
1326
|
"speed": speed,
|
|
1278
1327
|
"uuid": str(uuid4()),
|
|
1279
1328
|
"serial": serial,
|
|
@@ -1311,7 +1360,7 @@ class EzvizClient:
|
|
|
1311
1360
|
|
|
1312
1361
|
try:
|
|
1313
1362
|
req = self._session.post(
|
|
1314
|
-
"https://
|
|
1363
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_CAM_ENCRYPTKEY}",
|
|
1315
1364
|
data={
|
|
1316
1365
|
"checkcode": smscode,
|
|
1317
1366
|
"serial": serial,
|
|
@@ -1383,10 +1432,7 @@ class EzvizClient:
|
|
|
1383
1432
|
|
|
1384
1433
|
try:
|
|
1385
1434
|
req = self._session.get(
|
|
1386
|
-
"https://"
|
|
1387
|
-
+ self._token["api_url"]
|
|
1388
|
-
+ API_ENDPOINT_CAM_AUTH_CODE
|
|
1389
|
-
+ serial,
|
|
1435
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_CAM_AUTH_CODE}{serial}",
|
|
1390
1436
|
params=params,
|
|
1391
1437
|
timeout=self._timeout,
|
|
1392
1438
|
)
|
|
@@ -1429,7 +1475,7 @@ class EzvizClient:
|
|
|
1429
1475
|
|
|
1430
1476
|
try:
|
|
1431
1477
|
req = self._session.post(
|
|
1432
|
-
"https://
|
|
1478
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_CREATE_PANORAMIC}",
|
|
1433
1479
|
data={"deviceSerial": serial},
|
|
1434
1480
|
timeout=self._timeout,
|
|
1435
1481
|
)
|
|
@@ -1477,7 +1523,7 @@ class EzvizClient:
|
|
|
1477
1523
|
|
|
1478
1524
|
try:
|
|
1479
1525
|
req = self._session.post(
|
|
1480
|
-
"https://
|
|
1526
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_RETURN_PANORAMIC}",
|
|
1481
1527
|
data={"deviceSerial": serial},
|
|
1482
1528
|
timeout=self._timeout,
|
|
1483
1529
|
)
|
|
@@ -1532,9 +1578,7 @@ class EzvizClient:
|
|
|
1532
1578
|
|
|
1533
1579
|
try:
|
|
1534
1580
|
req = self._session.post(
|
|
1535
|
-
"https://"
|
|
1536
|
-
+ self._token["api_url"]
|
|
1537
|
-
+ API_ENDPOINT_PANORAMIC_DEVICES_OPERATION,
|
|
1581
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_PANORAMIC_DEVICES_OPERATION}",
|
|
1538
1582
|
data={
|
|
1539
1583
|
"x": f"{x_axis:.6f}",
|
|
1540
1584
|
"y": f"{y_axis:.6f}",
|
|
@@ -1568,9 +1612,7 @@ class EzvizClient:
|
|
|
1568
1612
|
if self._token["session_id"] and self._token["rf_session_id"]:
|
|
1569
1613
|
try:
|
|
1570
1614
|
req = self._session.put(
|
|
1571
|
-
"https://"
|
|
1572
|
-
+ self._token["api_url"]
|
|
1573
|
-
+ API_ENDPOINT_REFRESH_SESSION_ID,
|
|
1615
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_REFRESH_SESSION_ID}",
|
|
1574
1616
|
data={
|
|
1575
1617
|
"refreshSessionId": self._token["rf_session_id"],
|
|
1576
1618
|
"featureCode": FEATURE_CODE,
|
|
@@ -1632,7 +1674,7 @@ class EzvizClient:
|
|
|
1632
1674
|
"""Close Ezviz session and remove login session from ezviz servers."""
|
|
1633
1675
|
try:
|
|
1634
1676
|
req = self._session.delete(
|
|
1635
|
-
"https://
|
|
1677
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_LOGOUT}",
|
|
1636
1678
|
timeout=self._timeout,
|
|
1637
1679
|
)
|
|
1638
1680
|
req.raise_for_status()
|
|
@@ -1683,7 +1725,7 @@ class EzvizClient:
|
|
|
1683
1725
|
)
|
|
1684
1726
|
try:
|
|
1685
1727
|
req = self._session.post(
|
|
1686
|
-
"https://
|
|
1728
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_SET_DEFENCE_SCHEDULE}",
|
|
1687
1729
|
data={
|
|
1688
1730
|
"devTimingPlan": schedulestring,
|
|
1689
1731
|
},
|
|
@@ -1732,10 +1774,9 @@ class EzvizClient:
|
|
|
1732
1774
|
"""Set defence mode for all devices. The alarm panel from main page is used."""
|
|
1733
1775
|
if max_retries > MAX_RETRIES:
|
|
1734
1776
|
raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
|
|
1735
|
-
|
|
1736
1777
|
try:
|
|
1737
1778
|
req = self._session.post(
|
|
1738
|
-
"https://
|
|
1779
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_SWITCH_DEFENCE_MODE}",
|
|
1739
1780
|
data={
|
|
1740
1781
|
"groupId": -1,
|
|
1741
1782
|
"mode": mode,
|
|
@@ -1773,7 +1814,7 @@ class EzvizClient:
|
|
|
1773
1814
|
self,
|
|
1774
1815
|
serial: str,
|
|
1775
1816
|
enable: int = 1,
|
|
1776
|
-
channelno:
|
|
1817
|
+
channelno: int = 1,
|
|
1777
1818
|
max_retries: int = 0,
|
|
1778
1819
|
) -> bool:
|
|
1779
1820
|
"""Set do not disturb on camera with specified serial."""
|
|
@@ -1782,14 +1823,8 @@ class EzvizClient:
|
|
|
1782
1823
|
|
|
1783
1824
|
try:
|
|
1784
1825
|
req = self._session.put(
|
|
1785
|
-
"https://"
|
|
1786
|
-
|
|
1787
|
-
+ API_ENDPOINT_V3_ALARMS
|
|
1788
|
-
+ serial
|
|
1789
|
-
+ "/"
|
|
1790
|
-
+ channelno
|
|
1791
|
-
+ API_ENDPOINT_DO_NOT_DISTURB,
|
|
1792
|
-
data={"enable": enable, "channelNo": channelno, "deviceSerial": serial},
|
|
1826
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_V3_ALARMS}{serial}/{channelno}{API_ENDPOINT_DO_NOT_DISTURB}",
|
|
1827
|
+
data={"enable": enable},
|
|
1793
1828
|
timeout=self._timeout,
|
|
1794
1829
|
)
|
|
1795
1830
|
req.raise_for_status()
|
|
@@ -1813,11 +1848,47 @@ class EzvizClient:
|
|
|
1813
1848
|
|
|
1814
1849
|
return True
|
|
1815
1850
|
|
|
1851
|
+
def set_answer_call(
|
|
1852
|
+
self,
|
|
1853
|
+
serial: str,
|
|
1854
|
+
enable: int = 1,
|
|
1855
|
+
max_retries: int = 0,
|
|
1856
|
+
) -> bool:
|
|
1857
|
+
"""Set answer call on camera with specified serial."""
|
|
1858
|
+
if max_retries > MAX_RETRIES:
|
|
1859
|
+
raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
|
|
1860
|
+
try:
|
|
1861
|
+
req = self._session.put(
|
|
1862
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_CALLING_NOTIFY}{serial}{API_ENDPOINT_DO_NOT_DISTURB}",
|
|
1863
|
+
data={"deviceSerial": serial, "switchStatus": enable},
|
|
1864
|
+
timeout=self._timeout,
|
|
1865
|
+
)
|
|
1866
|
+
req.raise_for_status()
|
|
1867
|
+
|
|
1868
|
+
except requests.HTTPError as err:
|
|
1869
|
+
if err.response.status_code == 401:
|
|
1870
|
+
# session is wrong, need to re-log-in
|
|
1871
|
+
self.login()
|
|
1872
|
+
return self.set_answer_call(serial, enable, max_retries + 1)
|
|
1873
|
+
|
|
1874
|
+
raise HTTPError from err
|
|
1875
|
+
|
|
1876
|
+
try:
|
|
1877
|
+
json_output = req.json()
|
|
1878
|
+
|
|
1879
|
+
except ValueError as err:
|
|
1880
|
+
raise PyEzvizError("Could not decode response:" + str(err)) from err
|
|
1881
|
+
|
|
1882
|
+
if json_output["meta"]["code"] != 200:
|
|
1883
|
+
raise PyEzvizError(f"Could not set answer call: Got {json_output})")
|
|
1884
|
+
|
|
1885
|
+
return True
|
|
1886
|
+
|
|
1816
1887
|
def set_floodlight_brightness(
|
|
1817
1888
|
self,
|
|
1818
1889
|
serial: str,
|
|
1819
1890
|
luminance: int = 50,
|
|
1820
|
-
channelno:
|
|
1891
|
+
channelno: int = 1,
|
|
1821
1892
|
max_retries: int = 0,
|
|
1822
1893
|
) -> bool | str:
|
|
1823
1894
|
"""Set brightness on camera with adjustable light."""
|
|
@@ -1831,13 +1902,7 @@ class EzvizClient:
|
|
|
1831
1902
|
|
|
1832
1903
|
try:
|
|
1833
1904
|
req = self._session.post(
|
|
1834
|
-
"https://"
|
|
1835
|
-
+ self._token["api_url"]
|
|
1836
|
-
+ API_ENDPOINT_SET_LUMINANCE
|
|
1837
|
-
+ "/"
|
|
1838
|
-
+ serial
|
|
1839
|
-
+ "/"
|
|
1840
|
-
+ channelno,
|
|
1905
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_SET_LUMINANCE}{serial}/{channelno}",
|
|
1841
1906
|
data={
|
|
1842
1907
|
"luminance": luminance,
|
|
1843
1908
|
},
|
|
@@ -1871,7 +1936,7 @@ class EzvizClient:
|
|
|
1871
1936
|
self,
|
|
1872
1937
|
serial: str,
|
|
1873
1938
|
luminance: int = 50,
|
|
1874
|
-
channelno:
|
|
1939
|
+
channelno: int = 1,
|
|
1875
1940
|
max_retries: int = 0,
|
|
1876
1941
|
) -> bool | str:
|
|
1877
1942
|
"""Facade that changes the brightness to light bulbs or cameras' light."""
|
|
@@ -1922,16 +1987,13 @@ class EzvizClient:
|
|
|
1922
1987
|
raise PyEzvizError(
|
|
1923
1988
|
"Unproper sensibility for type 0 (should be within 1 to 6)."
|
|
1924
1989
|
)
|
|
1925
|
-
|
|
1926
1990
|
try:
|
|
1927
1991
|
req = self._session.post(
|
|
1928
|
-
"https://"
|
|
1929
|
-
+ self._token["api_url"]
|
|
1930
|
-
+ API_ENDPOINT_DETECTION_SENSIBILITY,
|
|
1992
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DETECTION_SENSIBILITY}",
|
|
1931
1993
|
data={
|
|
1932
1994
|
"subSerial": serial,
|
|
1933
1995
|
"type": type_value,
|
|
1934
|
-
"channelNo":
|
|
1996
|
+
"channelNo": 1,
|
|
1935
1997
|
"value": sensibility,
|
|
1936
1998
|
},
|
|
1937
1999
|
timeout=self._timeout,
|
|
@@ -1978,12 +2040,9 @@ class EzvizClient:
|
|
|
1978
2040
|
"""Get detection sensibility notifications."""
|
|
1979
2041
|
if max_retries > MAX_RETRIES:
|
|
1980
2042
|
raise PyEzvizError("Can't gather proper data. Max retries exceeded.")
|
|
1981
|
-
|
|
1982
2043
|
try:
|
|
1983
2044
|
req = self._session.post(
|
|
1984
|
-
"https://"
|
|
1985
|
-
+ self._token["api_url"]
|
|
1986
|
-
+ API_ENDPOINT_DETECTION_SENSIBILITY_GET,
|
|
2045
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DETECTION_SENSIBILITY_GET}",
|
|
1987
2046
|
data={
|
|
1988
2047
|
"subSerial": serial,
|
|
1989
2048
|
},
|
|
@@ -2045,11 +2104,7 @@ class EzvizClient:
|
|
|
2045
2104
|
|
|
2046
2105
|
try:
|
|
2047
2106
|
req = self._session.put(
|
|
2048
|
-
"https://"
|
|
2049
|
-
+ self._token["api_url"]
|
|
2050
|
-
+ API_ENDPOINT_DEVICES
|
|
2051
|
-
+ serial
|
|
2052
|
-
+ API_ENDPOINT_ALARM_SOUND,
|
|
2107
|
+
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}{API_ENDPOINT_ALARM_SOUND}",
|
|
2053
2108
|
data={
|
|
2054
2109
|
"enable": enable,
|
|
2055
2110
|
"soundType": sound_type,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
pyezvizapi/__init__.py,sha256=2YnR6s7OOOpV8QfxI6hdBKfc6WFerT55jqV8A1tDRSs,1167
|
|
2
2
|
pyezvizapi/__main__.py,sha256=a0JxEmkevYPmWK8V9cHt-7i8MtpztOl2IrrZ2SfEsrM,15718
|
|
3
|
-
pyezvizapi/api_endpoints.py,sha256=
|
|
3
|
+
pyezvizapi/api_endpoints.py,sha256=GtD8IC21yOt2450oR5-BAv2uMFJqwdRM-TZml2dUDh0,2408
|
|
4
4
|
pyezvizapi/camera.py,sha256=asP-PNoRPWR2KdlBir2NtLy4UpsLdOXzh2KyRfsir9s,11008
|
|
5
5
|
pyezvizapi/cas.py,sha256=d31ZflYSD9P40MnsNRNZbT0HVLvlnHokKpLbdAjWQ74,5631
|
|
6
|
-
pyezvizapi/client.py,sha256=
|
|
6
|
+
pyezvizapi/client.py,sha256=lxC0OCJBygCRPV8amxAq7skhGqMkMZSpEw6HvIMmvQY,72703
|
|
7
7
|
pyezvizapi/constants.py,sha256=NWOsr57VIh3t_3it-d6hDVDYHEFiQ2MjupBj6FMte4Y,10049
|
|
8
8
|
pyezvizapi/exceptions.py,sha256=TBJGh12s4UAMVY4k3jibfjEt9D4NVgKnv-397HmfEws,608
|
|
9
9
|
pyezvizapi/light_bulb.py,sha256=2v92JEQuItC8rtjxTC6qyvJaBDlcsEiVNXcNyQRltpc,5044
|
|
10
10
|
pyezvizapi/mqtt.py,sha256=Y4X99Z0Avm32SE8vog7CNsv6tGUPmPYUZUgPDGS0QJA,7866
|
|
11
11
|
pyezvizapi/test_cam_rtsp.py,sha256=w7GPcYIeK78TxL8zFDihdGSDQNWcYrurwZOr6uFzzgo,4902
|
|
12
12
|
pyezvizapi/utils.py,sha256=5J10o3h-y8prWDvl3LSAF-9wS1jBgBMg5cpAEebcuSM,4936
|
|
13
|
-
pyezvizapi-1.0.0.
|
|
14
|
-
pyezvizapi-1.0.0.
|
|
15
|
-
pyezvizapi-1.0.0.
|
|
16
|
-
pyezvizapi-1.0.0.
|
|
17
|
-
pyezvizapi-1.0.0.
|
|
18
|
-
pyezvizapi-1.0.0.
|
|
19
|
-
pyezvizapi-1.0.0.
|
|
13
|
+
pyezvizapi-1.0.0.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
+
pyezvizapi-1.0.0.4.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
+
pyezvizapi-1.0.0.4.dist-info/METADATA,sha256=Lp_WqBEG4tS50lPh3sk_5OlUoi1-WML-f6oqkyTjemI,672
|
|
16
|
+
pyezvizapi-1.0.0.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
17
|
+
pyezvizapi-1.0.0.4.dist-info/entry_points.txt,sha256=_BSJ3eNb2H_AZkRdsv1s4mojqWn3N7m503ujvg1SudA,56
|
|
18
|
+
pyezvizapi-1.0.0.4.dist-info/top_level.txt,sha256=gMZTelIi8z7pXyTCQLLaIkxVRrDQ_lS2NEv0WgfHrHs,11
|
|
19
|
+
pyezvizapi-1.0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|