pyimouapi 1.1.0__tar.gz → 1.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyimouapi
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: A package for imou open api
5
5
  Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
6
  Author: Imou-OpenPlatform
@@ -0,0 +1,299 @@
1
+ # API Endpoints
2
+ API_ENDPOINT_ACCESS_TOKEN = "/openapi/accessToken"
3
+ API_ENDPOINT_LIST_DEVICE_DETAILS = "/openapi/listDeviceDetailsByPage"
4
+ API_ENDPOINT_CONTROL_DEVICE_PTZ = "/openapi/controlMovePTZ"
5
+ API_ENDPOINT_MODIFY_DEVICE_ALARM_STATUS = "/openapi/modifyDeviceAlarmStatus"
6
+ API_ENDPOINT_GET_DEVICE_ALARM_PARAM = "/openapi/getDeviceAlarmParam"
7
+ API_ENDPOINT_GET_DEVICE_STATUS = "/openapi/getDeviceCameraStatus"
8
+ API_ENDPOINT_SET_DEVICE_STATUS = "/openapi/setDeviceCameraStatus"
9
+ API_ENDPOINT_GET_DEVICE_NIGHT_VISION_MODE = "/openapi/getNightVisionMode"
10
+ API_ENDPOINT_SET_DEVICE_NIGHT_VISION_MODE = "/openapi/setNightVisionMode"
11
+ API_ENDPOINT_DEVICE_STORAGE = "/openapi/deviceStorage"
12
+ API_ENDPOINT_RESTART_DEVICE = "/openapi/restartDevice"
13
+ API_ENDPOINT_BIND_DEVICE_LIVE = "/openapi/bindDeviceLive"
14
+ API_ENDPOINT_GET_DEVICE_ONLINE = "/openapi/deviceOnline"
15
+ API_ENDPOINT_GET_DEVICE_LIVE_INFO = "/openapi/getLiveStreamInfo"
16
+ API_ENDPOINT_SET_DEVICE_SNAP = "/openapi/setDeviceSnapEnhanced"
17
+ API_ENDPOINT_GET_IOT_DEVICE_PROPERTIES = "/openapi/getIotDeviceProperties"
18
+ API_ENDPOINT_SET_IOT_DEVICE_PROPERTIES = "/openapi/setIotDeviceProperties"
19
+ API_ENDPOINT_DEVICE_SD_CARD_STATUS = "/openapi/deviceSdcardStatus"
20
+ API_ENDPOINT_IOT_DEVICE_CONTROL = "/openapi/iotDeviceControl"
21
+ API_ENDPOINT_GET_DEVICE_POWER_INFO = "/openapi/getDevicePowerInfo"
22
+ API_ENDPOINT_GET_PRODUCT_MODEL = "/openapi/getProductModel"
23
+
24
+ # error_codes
25
+ ERROR_CODE_SUCCESS = "0"
26
+ ERROR_CODE_TOKEN_OVERDUE = "TK1002"
27
+ ERROR_CODE_INVALID_SIGN = "SN1001"
28
+ ERROR_CODE_INVALID_APP = "SN1004"
29
+ ERROR_CODE_DEVICE_OFFLINE = "DV1007"
30
+ ERROR_CODE_NO_STORAGE_MEDIUM = "DV1049"
31
+ ERROR_CODE_LIVE_NOT_EXIST = "LV1002"
32
+ ERROR_CODE_LIVE_ALREADY_EXIST = "LV1001"
33
+
34
+ # params key
35
+ PARAM_APP_ID = "appId"
36
+ PARAM_APP_SECRET = "appSecret"
37
+ PARAM_SYSTEM = "system"
38
+ PARAM_ACCESS_TOKEN = "accessToken"
39
+ PARAM_CURRENT_DOMAIN = "currentDomain"
40
+ PARAM_DEVICE_ID = "deviceId"
41
+ PARAM_CHANNEL_ID = "channelId"
42
+ PARAM_VER = "ver"
43
+ PARAM_SIGN = "sign"
44
+ PARAM_TIME = "time"
45
+ PARAM_NONCE = "nonce"
46
+ PARAM_PARAMS = "params"
47
+ PARAM_ID = "id"
48
+ PARAM_RESULT = "result"
49
+ PARAM_CODE = "code"
50
+ PARAM_MSG = "msg"
51
+ PARAM_DATA = "data"
52
+ PARAM_PAGE = "page"
53
+ PARAM_PAGE_SIZE = "pageSize"
54
+ PARAM_TOKEN = "token"
55
+ PARAM_PRODUCT_ID = "productId"
56
+ PARAM_PARENT_PRODUCT_ID = "parentProductId"
57
+ PARAM_PARENT_DEVICE_ID = "parentDeviceId"
58
+ PARAM_CHANNEL_NUM = "channelNum"
59
+ PARAM_MODE = "mode"
60
+ PARAM_ENABLE_TYPE = "enableType"
61
+ PARAM_ENABLE = "enable"
62
+ PARAM_COUNT = "count"
63
+ PARAM_DEVICE_LIST = "deviceList"
64
+ PARAM_DEVICE_NAME = "deviceName"
65
+ PARAM_DEVICE_STATUS = "deviceStatus"
66
+ PARAM_DEVICE_ABILITY = "deviceAbility"
67
+ PARAM_DEVICE_VERSION = "deviceVersion"
68
+ PARAM_BRAND = "brand"
69
+ PARAM_DEVICE_MODEL = "deviceModel"
70
+ PARAM_CHANNEL_LIST = "channelList"
71
+ PARAM_CHANNEL_NAME = "channelName"
72
+ PARAM_CHANNEL_STATUS = "channelStatus"
73
+ PARAM_CHANNEL_ABILITY = "channelAbility"
74
+ PARAM_STREAM_ID = "streamId"
75
+ PARAM_OPERATION = "operation"
76
+ PARAM_DURATION = "duration"
77
+ PARAM_PROPERTIES = "properties"
78
+ PARAM_API_URL = "api_url"
79
+ PARAM_STATUS = "status"
80
+ PARAM_CURRENT_OPTION = "current_option"
81
+ PARAM_MODES = "modes"
82
+ PARAM_OPTIONS = "options"
83
+ PARAM_CHANNELS = "channels"
84
+ PARAM_USED_BYTES = "usedBytes"
85
+ PARAM_TOTAL_BYTES = "totalBytes"
86
+ PARAM_STREAMS = "streams"
87
+ PARAM_HLS = "hls"
88
+ PARAM_URL = "url"
89
+ PARAM_KEY = "key"
90
+ PARAM_DEFAULT = "default"
91
+ PARAM_REF = "ref"
92
+ PARAM_CONTENT = "content"
93
+ PARAM_ON = "on"
94
+ PARAM_BUTTON_TYPE_REF = "button_type_ref"
95
+ PARAM_SENSOR_TYPE_REF = "sensor_type_ref"
96
+ PARAM_SWITCH_TYPE_REF = "switch_type_ref"
97
+ PARAM_SELECT_TYPE_REF = "select_type_ref"
98
+ PARAM_BINARY_SENSOR_TYPE_REF = "binary_sensor_type_ref"
99
+ PARAM_ONLINE = "onLine"
100
+ PARAM_HD = "HD"
101
+ PARAM_MULTI_FLAG = "multiFlag"
102
+ PARAM_MOTION_DETECT = "motion_detect"
103
+ PARAM_STORAGE_USED = "storage_used"
104
+ PARAM_RESTART_DEVICE = "restart_device"
105
+ PARAM_NIGHT_VISION_MODE = "night_vision_mode"
106
+ PARAM_PTZ = "ptz"
107
+ PARAM_TEMPERATURE_CURRENT = "temperature_current"
108
+ PARAM_HUMIDITY_CURRENT = "humidity_current"
109
+ PARAM_BATTERY = "battery"
110
+ PARAM_ELECTRICITYS = "electricitys"
111
+ PARAM_ELECTRIC = "electric"
112
+ PARAM_LITELEC = "litElec"
113
+ PARAM_ALKELEC = "alkElec"
114
+ PARAM_SERVICES = "services"
115
+ PARAM_STATE = "state"
116
+ PARAM_TYPE = "type"
117
+ PARAM_EXCEPTS = "excepts"
118
+
119
+
120
+ # Required capacity for various switch types
121
+ SWITCH_TYPE_ABILITY = {
122
+ "motion_detect": ["MobileDetect", "MotionDetect", "AlarmMD"],
123
+ "close_camera": ["CloseCamera"],
124
+ "white_light": ["WhiteLight", "ChnWhiteLight"],
125
+ "ab_alarm_sound": ["AbAlarmSound"],
126
+ "audio_encode_control": ["AudioEncodeControl", "AudioEncodeControlV2"],
127
+ "header_detect": ["HeaderDetect", "AiHuman", "SMDH"],
128
+ }
129
+ SWITCH_TYPE_REF = {
130
+ "motion_detect": [{"ref": "14800", "default": False, "type": "properties"}],
131
+ "close_camera": [{"ref": "13100", "default": False, "type": "properties"}],
132
+ "white_light": [{"ref": "19700", "default": False, "type": "properties"}],
133
+ "ab_alarm_sound": [
134
+ {"ref": "14200", "default": False, "type": "properties"},
135
+ {"ref": "115300", "default": False, "type": "properties"},
136
+ ],
137
+ "audio_encode_control": [
138
+ {"ref": "13900", "default": False, "type": "properties"},
139
+ {"ref": "111900", "default": False, "type": "properties"},
140
+ {"ref": "103800", "default": False, "type": "properties"},
141
+ ],
142
+ "header_detect": [
143
+ {"ref": "17100", "default": False, "type": "properties"},
144
+ {"ref": "17900", "default": False, "type": "properties"},
145
+ {"ref": "108900", "default": False, "type": "properties"},
146
+ ],
147
+ "light": [{"ref": "11400", "default": False, "type": "properties"}],
148
+ }
149
+ # Required capacity for various button types
150
+ BUTTON_TYPE_ABILITY = {
151
+ "restart_device": ["Reboot"],
152
+ "ptz_up": ["PT", "PTZ"],
153
+ "ptz_down": ["PT", "PTZ"],
154
+ "ptz_left": ["PT", "PTZ"],
155
+ "ptz_right": ["PT", "PTZ"],
156
+ }
157
+ BUTTON_TYPE_REF = {
158
+ "restart_device": [{"ref": "2300", "type": "services"}],
159
+ "mute": [
160
+ {
161
+ "ref": "21600",
162
+ "type": "services",
163
+ "excepts": [
164
+ "emi4a5sapwg0pnj0",
165
+ "BZFACWD1",
166
+ "Q5egDcb6",
167
+ "2BFWLKHL",
168
+ "2BTLSNHP",
169
+ "GF3QAMMD",
170
+ "35gL0U5A",
171
+ ],
172
+ },
173
+ {
174
+ "ref": "2200",
175
+ "type": "services",
176
+ "excepts": [
177
+ "emi4a5sapwg0pnj0",
178
+ "BZFACWD1",
179
+ "Q5egDcb6",
180
+ "2BFWLKHL",
181
+ "2BTLSNHP",
182
+ "GF3QAMMD",
183
+ "35gL0U5A",
184
+ ],
185
+ },
186
+ ],
187
+ }
188
+ # Required capacity for various select types
189
+ SELECT_TYPE_ABILITY = {
190
+ "night_vision_mode": ["NVM"],
191
+ }
192
+ SELECT_TYPE_REF = {
193
+ "night_vision_mode": [
194
+ {
195
+ "ref": "17400",
196
+ "default": "0",
197
+ "options": ["0", "1", "2", "3", "5"],
198
+ "type": "properties",
199
+ },
200
+ {
201
+ "ref": "139700",
202
+ "default": "0",
203
+ "options": ["0", "1", "2", "3", "4"],
204
+ "type": "properties",
205
+ },
206
+ {"ref": "112400", "default": "2", "options": ["2", "3"], "type": "properties"},
207
+ ],
208
+ "mode": [
209
+ {
210
+ "ref": "15200",
211
+ "default": "0",
212
+ "type": "properties",
213
+ "options": ["0", "1", "2"],
214
+ }
215
+ ],
216
+ "device_volume": [
217
+ {
218
+ "ref": "15400",
219
+ "default": "0",
220
+ "type": "properties",
221
+ "options": ["-1", "0", "1", "2"],
222
+ }
223
+ ],
224
+ }
225
+ # Required capacity for various sensor types
226
+ SENSOR_TYPE_ABILITY = {
227
+ "storage_used": ["LocalStorage", "LocalStorageEnable"],
228
+ "battery": ["Electric"],
229
+ }
230
+ SENSOR_TYPE_REF = {
231
+ "battery": [{"ref": "11600", "default": "15", "type": "properties"}],
232
+ "temperature_current": [
233
+ {
234
+ "ref": "16000",
235
+ "type": "properties",
236
+ "default": "10",
237
+ }
238
+ ],
239
+ "humidity_current": [
240
+ {
241
+ "ref": "16100",
242
+ "type": "properties",
243
+ "default": "10",
244
+ }
245
+ ],
246
+ }
247
+
248
+ BINARY_SENSOR_TYPE_ABILITY = {}
249
+ BINARY_SENSOR_TYPE_REF = {
250
+ "door_contact_status": [
251
+ {
252
+ "ref": "16300",
253
+ "type": "properties",
254
+ "default": False,
255
+ }
256
+ ]
257
+ }
258
+
259
+ # Levels of capacity
260
+ ABILITY_LEVEL_TYPE = {
261
+ "MobileDetect": 2,
262
+ "MotionDetect": 2,
263
+ "PT": 2,
264
+ "PTZ": 2,
265
+ "CloseCamera": 2,
266
+ "WhiteLight": 1,
267
+ "ChnWhiteLight": 2,
268
+ "AbAlarmSound": 1,
269
+ "AudioEncodeControl": 2,
270
+ "AudioEncodeControlV2": 2,
271
+ "NVM": 2,
272
+ "LocalStorage": 1,
273
+ "LocalStorageEnable": 1,
274
+ "Reboot": 1,
275
+ "Electric": 3,
276
+ "HeaderDetect": 2,
277
+ "AlarmMD": 2,
278
+ "HumanDetect": 2,
279
+ "AiHuman": 2,
280
+ "SMDH": 2,
281
+ }
282
+
283
+
284
+ # The parameter values for switch
285
+ SWITCH_TYPE_ENABLE = {
286
+ "motion_detect": ["motionDetect", "mobileDetect"],
287
+ "close_camera": ["closeCamera"],
288
+ "white_light": ["whiteLight"],
289
+ "audio_encode_control": ["audioEncodeControl"],
290
+ "ab_alarm_sound": ["abAlarmSound"],
291
+ "header_detect": ["headerDetect", "aiHuman", "smdHuman"],
292
+ }
293
+
294
+ BUTTON_TYPE_PARAM_VALUE = {
295
+ "ptz_up": 0,
296
+ "ptz_down": 1,
297
+ "ptz_left": 2,
298
+ "ptz_right": 3,
299
+ }
@@ -48,6 +48,7 @@ from .const import (
48
48
  API_ENDPOINT_IOT_DEVICE_CONTROL,
49
49
  PARAM_MULTI_FLAG,
50
50
  API_ENDPOINT_GET_DEVICE_POWER_INFO,
51
+ API_ENDPOINT_GET_PRODUCT_MODEL,
51
52
  )
52
53
  from .openapi import ImouOpenApiClient
53
54
 
@@ -204,7 +205,7 @@ class ImouDeviceManager:
204
205
  device_name = device[PARAM_DEVICE_NAME]
205
206
  device_status = device[PARAM_DEVICE_STATUS]
206
207
  brand = device[PARAM_BRAND]
207
- device_model = device.get(PARAM_DEVICE_MODEL,"unknown")
208
+ device_model = device.get(PARAM_DEVICE_MODEL, "unknown")
208
209
  imou_device = ImouDevice(
209
210
  device_id, device_name, device_status, brand, device_model
210
211
  )
@@ -428,10 +429,18 @@ class ImouDeviceManager:
428
429
  API_ENDPOINT_IOT_DEVICE_CONTROL, params
429
430
  )
430
431
 
431
- async def async_get_device_power_info(self, device_id):
432
+ async def async_get_device_power_info(self, device_id: str):
432
433
  params = {
433
434
  PARAM_DEVICE_ID: device_id,
434
435
  }
435
436
  return await self._imou_api_client.async_request_api(
436
437
  API_ENDPOINT_GET_DEVICE_POWER_INFO, params
437
438
  )
439
+
440
+ async def async_get_product_model(self, product_id: str):
441
+ params = {
442
+ PARAM_DEVICE_ID: product_id,
443
+ }
444
+ return await self._imou_api_client.async_request_api(
445
+ API_ENDPOINT_GET_PRODUCT_MODEL, params
446
+ )