pyimouapi 1.2.7__tar.gz → 1.2.9__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.
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/PKG-INFO +3 -13
- pyimouapi-1.2.9/pyimouapi/__init__.py +20 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi/const.py +2 -1
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi/device.py +84 -43
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi/ha_device.py +525 -359
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi/openapi.py +47 -22
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi.egg-info/PKG-INFO +3 -13
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi.egg-info/SOURCES.txt +6 -1
- pyimouapi-1.2.9/pyproject.toml +70 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/setup.py +5 -3
- pyimouapi-1.2.9/tests/test_collect_property_entities.py +49 -0
- pyimouapi-1.2.9/tests/test_device_summaries.py +89 -0
- pyimouapi-1.2.9/tests/test_lookup_property.py +46 -0
- pyimouapi-1.2.9/tests/test_message_callback.py +50 -0
- pyimouapi-1.2.9/tests/test_update_from_detail.py +108 -0
- pyimouapi-1.2.7/pyimouapi/__init__.py +0 -9
- pyimouapi-1.2.7/pyproject.toml +0 -3
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/LICENSE +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/README.md +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi/exceptions.py +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi.egg-info/dependency_links.txt +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi.egg-info/requires.txt +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/pyimouapi.egg-info/top_level.txt +0 -0
- {pyimouapi-1.2.7 → pyimouapi-1.2.9}/setup.cfg +0 -0
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyimouapi
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.9
|
|
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
|
|
7
|
-
Author-email: cloud_openteam_service@imou.com
|
|
7
|
+
Author-email: Imou-OpenPlatform <cloud_openteam_service@imou.com>
|
|
8
8
|
License: MIT
|
|
9
|
-
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
9
|
+
Project-URL: Homepage, https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
|
|
13
10
|
Requires-Python: >=3.11
|
|
14
11
|
Description-Content-Type: text/markdown
|
|
15
12
|
License-File: LICENSE
|
|
16
13
|
Requires-Dist: aiohttp<4.0,>=3.11.9
|
|
17
14
|
Requires-Dist: simpleeval>=1.0.3
|
|
18
15
|
Dynamic: author
|
|
19
|
-
Dynamic: author-email
|
|
20
|
-
Dynamic: classifier
|
|
21
|
-
Dynamic: description
|
|
22
|
-
Dynamic: description-content-type
|
|
23
16
|
Dynamic: home-page
|
|
24
|
-
Dynamic: license
|
|
25
17
|
Dynamic: license-file
|
|
26
|
-
Dynamic: requires-dist
|
|
27
18
|
Dynamic: requires-python
|
|
28
|
-
Dynamic: summary
|
|
29
19
|
|
|
30
20
|
# pyimouapi
|
|
31
21
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
__version__ = "1.2.9"
|
|
2
|
+
|
|
3
|
+
from .device import ImouChannel, ImouDevice, ImouDeviceManager
|
|
4
|
+
from .exceptions import (
|
|
5
|
+
ConnectFailedException,
|
|
6
|
+
InvalidAppIdOrSecretException,
|
|
7
|
+
RequestFailedException,
|
|
8
|
+
)
|
|
9
|
+
from .openapi import ImouOpenApiClient
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"ConnectFailedException",
|
|
13
|
+
"ImouChannel",
|
|
14
|
+
"ImouDevice",
|
|
15
|
+
"ImouDeviceManager",
|
|
16
|
+
"ImouOpenApiClient",
|
|
17
|
+
"InvalidAppIdOrSecretException",
|
|
18
|
+
"RequestFailedException",
|
|
19
|
+
"__version__",
|
|
20
|
+
]
|
|
@@ -22,6 +22,7 @@ API_ENDPOINT_GET_DEVICE_POWER_INFO = "/openapi/getDevicePowerInfo"
|
|
|
22
22
|
API_ENDPOINT_GET_PRODUCT_MODEL = "/openapi/getProductModel"
|
|
23
23
|
API_ENDPOINT_GET_IOT_DEVICE_DETAIL_INFO = "/openapi/getIotDeviceDetailInfo"
|
|
24
24
|
API_ENDPOINT_WAKE_UP_DEVICE = "/openapi/wakeUpDevice"
|
|
25
|
+
API_ENDPOINT_SET_MESSAGE_CALLBACK = "/openapi/setMessageCallback"
|
|
25
26
|
|
|
26
27
|
# error_codes
|
|
27
28
|
ERROR_CODE_SUCCESS = "0"
|
|
@@ -518,5 +519,5 @@ NIGHT_VISION_MODE_MAP = {
|
|
|
518
519
|
"infrared": "Infrared",
|
|
519
520
|
"off": "Off",
|
|
520
521
|
"lowlight": "LowLight",
|
|
521
|
-
"smartlowlight": "SmartLowLight"
|
|
522
|
+
"smartlowlight": "SmartLowLight",
|
|
522
523
|
}
|
|
@@ -1,69 +1,78 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from dataclasses import dataclass
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
5
6
|
from .const import (
|
|
6
|
-
|
|
7
|
-
PARAM_PAGE_SIZE,
|
|
8
|
-
PARAM_PAGE,
|
|
9
|
-
PARAM_DEVICE_ID,
|
|
10
|
-
PARAM_CHANNEL_ID,
|
|
7
|
+
API_ENDPOINT_BIND_DEVICE_LIVE,
|
|
11
8
|
API_ENDPOINT_CONTROL_DEVICE_PTZ,
|
|
12
|
-
|
|
13
|
-
API_ENDPOINT_GET_DEVICE_STATUS,
|
|
14
|
-
API_ENDPOINT_SET_DEVICE_STATUS,
|
|
15
|
-
API_ENDPOINT_GET_DEVICE_NIGHT_VISION_MODE,
|
|
9
|
+
API_ENDPOINT_DEVICE_SD_CARD_STATUS,
|
|
16
10
|
API_ENDPOINT_DEVICE_STORAGE,
|
|
17
|
-
|
|
18
|
-
API_ENDPOINT_BIND_DEVICE_LIVE,
|
|
19
|
-
API_ENDPOINT_GET_DEVICE_ONLINE,
|
|
11
|
+
API_ENDPOINT_GET_DEVICE_ALARM_PARAM,
|
|
20
12
|
API_ENDPOINT_GET_DEVICE_LIVE_INFO,
|
|
13
|
+
API_ENDPOINT_GET_DEVICE_NIGHT_VISION_MODE,
|
|
14
|
+
API_ENDPOINT_GET_DEVICE_ONLINE,
|
|
15
|
+
API_ENDPOINT_GET_DEVICE_POWER_INFO,
|
|
16
|
+
API_ENDPOINT_GET_DEVICE_STATUS,
|
|
17
|
+
API_ENDPOINT_GET_IOT_DEVICE_DETAIL_INFO,
|
|
18
|
+
API_ENDPOINT_GET_IOT_DEVICE_PROPERTIES,
|
|
19
|
+
API_ENDPOINT_GET_PRODUCT_MODEL,
|
|
20
|
+
API_ENDPOINT_IOT_DEVICE_CONTROL,
|
|
21
|
+
API_ENDPOINT_LIST_DEVICE_DETAILS,
|
|
22
|
+
API_ENDPOINT_MODIFY_DEVICE_ALARM_STATUS,
|
|
23
|
+
API_ENDPOINT_RESTART_DEVICE,
|
|
24
|
+
API_ENDPOINT_SET_DEVICE_NIGHT_VISION_MODE,
|
|
21
25
|
API_ENDPOINT_SET_DEVICE_SNAP,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
API_ENDPOINT_SET_DEVICE_STATUS,
|
|
27
|
+
API_ENDPOINT_SET_IOT_DEVICE_PROPERTIES,
|
|
28
|
+
API_ENDPOINT_WAKE_UP_DEVICE,
|
|
29
|
+
NIGHT_VISION_MODE_MAP,
|
|
30
|
+
PARAM_ABILITY_REFS,
|
|
31
|
+
PARAM_ACCESS_TYPE,
|
|
32
|
+
PARAM_BRAND,
|
|
33
|
+
PARAM_CHANNEL_ABILITY,
|
|
34
|
+
PARAM_CHANNEL_ID,
|
|
35
|
+
PARAM_CHANNEL_LIST,
|
|
36
|
+
PARAM_CHANNEL_NAME,
|
|
37
|
+
PARAM_CHANNEL_NUM,
|
|
38
|
+
PARAM_CHANNEL_STATUS,
|
|
39
|
+
PARAM_CHANNELS,
|
|
40
|
+
PARAM_CONTENT,
|
|
25
41
|
PARAM_COUNT,
|
|
42
|
+
PARAM_DEVICE_ABILITY,
|
|
43
|
+
PARAM_DEVICE_ID,
|
|
26
44
|
PARAM_DEVICE_LIST,
|
|
45
|
+
PARAM_DEVICE_MODEL,
|
|
27
46
|
PARAM_DEVICE_NAME,
|
|
28
47
|
PARAM_DEVICE_STATUS,
|
|
29
|
-
PARAM_DEVICE_ABILITY,
|
|
30
48
|
PARAM_DEVICE_VERSION,
|
|
31
|
-
PARAM_BRAND,
|
|
32
|
-
PARAM_DEVICE_MODEL,
|
|
33
|
-
PARAM_CHANNEL_LIST,
|
|
34
|
-
PARAM_CHANNEL_NAME,
|
|
35
|
-
PARAM_CHANNEL_STATUS,
|
|
36
|
-
PARAM_CHANNEL_ABILITY,
|
|
37
|
-
PARAM_STREAM_ID,
|
|
38
|
-
PARAM_OPERATION,
|
|
39
49
|
PARAM_DURATION,
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
PARAM_ENABLE,
|
|
51
|
+
PARAM_ENABLE_TYPE,
|
|
52
|
+
PARAM_MODE,
|
|
53
|
+
PARAM_MULTI_FLAG,
|
|
54
|
+
PARAM_OPERATION,
|
|
55
|
+
PARAM_PAGE,
|
|
56
|
+
PARAM_PAGE_SIZE,
|
|
57
|
+
PARAM_PARENT_DEVICE_ID,
|
|
58
|
+
PARAM_PARENT_PRODUCT_ID,
|
|
42
59
|
PARAM_PRODUCT_ID,
|
|
43
60
|
PARAM_PROPERTIES,
|
|
44
|
-
API_ENDPOINT_GET_IOT_DEVICE_PROPERTIES,
|
|
45
|
-
API_ENDPOINT_SET_IOT_DEVICE_PROPERTIES,
|
|
46
|
-
API_ENDPOINT_DEVICE_SD_CARD_STATUS,
|
|
47
|
-
PARAM_CHANNEL_NUM,
|
|
48
|
-
PARAM_PARENT_PRODUCT_ID,
|
|
49
|
-
PARAM_PARENT_DEVICE_ID,
|
|
50
61
|
PARAM_REF,
|
|
51
|
-
|
|
52
|
-
API_ENDPOINT_IOT_DEVICE_CONTROL,
|
|
53
|
-
PARAM_MULTI_FLAG,
|
|
54
|
-
API_ENDPOINT_GET_DEVICE_POWER_INFO,
|
|
55
|
-
API_ENDPOINT_GET_PRODUCT_MODEL,
|
|
56
|
-
API_ENDPOINT_GET_IOT_DEVICE_DETAIL_INFO,
|
|
57
|
-
PARAM_ABILITY_REFS,
|
|
58
|
-
PARAM_CHANNELS,
|
|
59
|
-
PARAM_ACCESS_TYPE,
|
|
60
|
-
API_ENDPOINT_WAKE_UP_DEVICE,
|
|
62
|
+
PARAM_STREAM_ID,
|
|
61
63
|
PARAM_URL,
|
|
62
|
-
NIGHT_VISION_MODE_MAP,
|
|
63
64
|
)
|
|
64
65
|
from .openapi import ImouOpenApiClient
|
|
65
66
|
|
|
66
67
|
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class ImouDeviceSummary:
|
|
70
|
+
device_id: str
|
|
71
|
+
name: str
|
|
72
|
+
model: str
|
|
73
|
+
status: str # "0" offline, "1" online
|
|
74
|
+
|
|
75
|
+
|
|
67
76
|
class ImouChannel:
|
|
68
77
|
def __init__(
|
|
69
78
|
self,
|
|
@@ -286,6 +295,38 @@ class ImouDeviceManager:
|
|
|
286
295
|
devices.extend(await self.async_get_devices(page + 1, page_size))
|
|
287
296
|
return devices
|
|
288
297
|
|
|
298
|
+
async def async_get_device_summaries(
|
|
299
|
+
self, page: int = 1, page_size: int = 50
|
|
300
|
+
) -> list[ImouDeviceSummary]:
|
|
301
|
+
params = {
|
|
302
|
+
PARAM_PAGE: page,
|
|
303
|
+
PARAM_PAGE_SIZE: page_size,
|
|
304
|
+
}
|
|
305
|
+
data = await self._imou_api_client.async_request_api(
|
|
306
|
+
API_ENDPOINT_LIST_DEVICE_DETAILS, params
|
|
307
|
+
)
|
|
308
|
+
if data[PARAM_COUNT] == 0:
|
|
309
|
+
return []
|
|
310
|
+
summaries: list[ImouDeviceSummary] = []
|
|
311
|
+
for device in data[PARAM_DEVICE_LIST]:
|
|
312
|
+
device_id = device.get(PARAM_DEVICE_ID)
|
|
313
|
+
if not device_id:
|
|
314
|
+
continue
|
|
315
|
+
name = device.get(PARAM_DEVICE_NAME) or device_id
|
|
316
|
+
model = device.get(PARAM_DEVICE_MODEL, "")
|
|
317
|
+
status = str(device.get(PARAM_DEVICE_STATUS, ""))
|
|
318
|
+
summaries.append(
|
|
319
|
+
ImouDeviceSummary(
|
|
320
|
+
device_id=device_id,
|
|
321
|
+
name=name,
|
|
322
|
+
model=model,
|
|
323
|
+
status=status,
|
|
324
|
+
)
|
|
325
|
+
)
|
|
326
|
+
if data[PARAM_COUNT] >= page_size:
|
|
327
|
+
summaries.extend(await self.async_get_device_summaries(page + 1, page_size))
|
|
328
|
+
return summaries
|
|
329
|
+
|
|
289
330
|
async def async_control_device_ptz(
|
|
290
331
|
self, device_id: str, channel_id: str, operation: int, duration: int
|
|
291
332
|
) -> None:
|