pyimouapi 1.3.5__tar.gz → 1.4.1__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.3.5 → pyimouapi-1.4.1}/PKG-INFO +5 -3
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/README.md +4 -2
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/__init__.py +1 -1
- pyimouapi-1.4.1/pyimouapi/alarm_mode.py +22 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/const.py +101 -29
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/device.py +63 -7
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/ha_device.py +308 -123
- pyimouapi-1.4.1/pyimouapi/pic_decode.py +220 -0
- pyimouapi-1.4.1/pyimouapi/push.py +187 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/select_option.py +1 -11
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/PKG-INFO +5 -3
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/SOURCES.txt +10 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyproject.toml +1 -1
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/setup.py +1 -1
- pyimouapi-1.4.1/tests/test_alarm_control_panel.py +65 -0
- pyimouapi-1.4.1/tests/test_alarm_mode.py +33 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_channel_id_and_api_guards.py +1 -1
- pyimouapi-1.4.1/tests/test_device_stream.py +123 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_event_identifier_map.py +9 -0
- pyimouapi-1.4.1/tests/test_feature_switches.py +88 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_get_devices.py +28 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_motion_detect_excepts.py +4 -6
- pyimouapi-1.4.1/tests/test_pic_decode.py +203 -0
- pyimouapi-1.4.1/tests/test_push.py +205 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_select_option.py +2 -26
- pyimouapi-1.4.1/tests/test_shared_status_reads.py +219 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_status_read_concurrency.py +1 -1
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_update_from_detail.py +84 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_write_optimistic_state.py +6 -10
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/LICENSE +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/collection_point.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/exceptions.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/openapi.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/py.typed +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/sensor.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi/siren.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/dependency_links.txt +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/not-zip-safe +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/requires.txt +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/pyimouapi.egg-info/top_level.txt +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/setup.cfg +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_accessory_device_id.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_auth_failure_propagates.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_bind_device.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_collect_property_entities.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_collection_point.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_connection_pool.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_device_image.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_device_summaries.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_entity_tables_golden.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_lookup_property.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_message_callback.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_openapi_http.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_packaging.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_product_id_guard.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_sensor_normalize.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_services_entities_concurrency.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_set_text_value.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_siren.py +0 -0
- {pyimouapi-1.3.5 → pyimouapi-1.4.1}/tests/test_switch_status_aggregation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyimouapi
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
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
|
|
@@ -31,8 +31,10 @@ Async Python client for the **Imou Open Platform** cloud APIs. Built on **aiohtt
|
|
|
31
31
|
|--------|------|
|
|
32
32
|
| `pyimouapi.openapi` | `ImouOpenApiClient` — auth, signing, token lifecycle, HTTP calls |
|
|
33
33
|
| `pyimouapi.device` | `ImouDeviceManager`, `ImouDevice`, `ImouChannel` — listing, PTZ, alarms, storage, collection points (`getCollection` / `turnCollection`), and related endpoints |
|
|
34
|
-
| `pyimouapi.collection_point` | Parsing helpers for PaaS / IoT collection point
|
|
35
|
-
| `pyimouapi.
|
|
34
|
+
| `pyimouapi.collection_point` | Parsing helpers for PaaS / IoT collection point name lists |
|
|
35
|
+
| `pyimouapi.push` | Open Platform event-push helpers: normalize payload fields, alarm vs status `msgType`, IoT envelope check, event-ref lookup, picture URLs (`thumbUrl` first, then `picUrlArray` / `picUrlArr` / `picUrl`) |
|
|
36
|
+
| `pyimouapi.pic_decode` | `LCOpenPicDecoder` — decrypts alarm pictures **you have already downloaded**, through the official LCOpenSDK native libraries (linux x86-64). Also TCM detection and encrypt-key resolution. No Open Platform call, token, or CA bundle is involved |
|
|
37
|
+
| `pyimouapi.ha_device` | `ImouHaDeviceManager`, `ImouHaDevice`, … — aggregated “device model” helpers for automation stacks (including `alarm_control_panel` for IoT ref `15200`, feature switches, and `select.collection_point` when the device exposes `CollectionPoint` or IoT refs `21500`/`22000`) |
|
|
36
38
|
| `pyimouapi.exceptions` | `ImouException` and typed errors (connect, request, invalid credentials, …) |
|
|
37
39
|
|
|
38
40
|
The top-level `pyimouapi` package re-exports common symbols. Import submodules directly when needed, for example `from pyimouapi.ha_device import ImouHaDeviceManager`.
|
|
@@ -12,8 +12,10 @@ Async Python client for the **Imou Open Platform** cloud APIs. Built on **aiohtt
|
|
|
12
12
|
|--------|------|
|
|
13
13
|
| `pyimouapi.openapi` | `ImouOpenApiClient` — auth, signing, token lifecycle, HTTP calls |
|
|
14
14
|
| `pyimouapi.device` | `ImouDeviceManager`, `ImouDevice`, `ImouChannel` — listing, PTZ, alarms, storage, collection points (`getCollection` / `turnCollection`), and related endpoints |
|
|
15
|
-
| `pyimouapi.collection_point` | Parsing helpers for PaaS / IoT collection point
|
|
16
|
-
| `pyimouapi.
|
|
15
|
+
| `pyimouapi.collection_point` | Parsing helpers for PaaS / IoT collection point name lists |
|
|
16
|
+
| `pyimouapi.push` | Open Platform event-push helpers: normalize payload fields, alarm vs status `msgType`, IoT envelope check, event-ref lookup, picture URLs (`thumbUrl` first, then `picUrlArray` / `picUrlArr` / `picUrl`) |
|
|
17
|
+
| `pyimouapi.pic_decode` | `LCOpenPicDecoder` — decrypts alarm pictures **you have already downloaded**, through the official LCOpenSDK native libraries (linux x86-64). Also TCM detection and encrypt-key resolution. No Open Platform call, token, or CA bundle is involved |
|
|
18
|
+
| `pyimouapi.ha_device` | `ImouHaDeviceManager`, `ImouHaDevice`, … — aggregated “device model” helpers for automation stacks (including `alarm_control_panel` for IoT ref `15200`, feature switches, and `select.collection_point` when the device exposes `CollectionPoint` or IoT refs `21500`/`22000`) |
|
|
17
19
|
| `pyimouapi.exceptions` | `ImouException` and typed errors (connect, request, invalid credentials, …) |
|
|
18
20
|
|
|
19
21
|
The top-level `pyimouapi` package re-exports common symbols. Import submodules directly when needed, for example `from pyimouapi.ha_device import ImouHaDeviceManager`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Friendly keys for IoT alarm mode (ref 15200)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
ALARM_MODES: tuple[str, ...] = ("home", "away", "disarm")
|
|
6
|
+
|
|
7
|
+
_RAW_TO_FRIENDLY = {"0": "home", "1": "away", "2": "disarm"}
|
|
8
|
+
_FRIENDLY_TO_RAW = {v: k for k, v in _RAW_TO_FRIENDLY.items()}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def to_friendly(raw: object) -> str:
|
|
12
|
+
"""Map vendor raw (int or str) to home / away / disarm."""
|
|
13
|
+
key = "" if raw is None else str(raw).strip()
|
|
14
|
+
return _RAW_TO_FRIENDLY.get(key, key)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def to_raw(mode: str) -> str:
|
|
18
|
+
"""Map home / away / disarm to the IoT integer string."""
|
|
19
|
+
key = mode.strip().lower()
|
|
20
|
+
if key not in _FRIENDLY_TO_RAW:
|
|
21
|
+
raise ValueError(f"unknown alarm mode: {mode!r}")
|
|
22
|
+
return _FRIENDLY_TO_RAW[key]
|
|
@@ -16,6 +16,7 @@ API_ENDPOINT_BIND_DEVICE = "/openapi/bindDevice"
|
|
|
16
16
|
API_ENDPOINT_BIND_DEVICE_LIVE = "/openapi/bindDeviceLive"
|
|
17
17
|
API_ENDPOINT_GET_DEVICE_ONLINE = "/openapi/deviceOnline"
|
|
18
18
|
API_ENDPOINT_GET_DEVICE_LIVE_INFO = "/openapi/getLiveStreamInfo"
|
|
19
|
+
API_ENDPOINT_GET_STREAM_URL = "/openapi/getStreamUrl"
|
|
19
20
|
API_ENDPOINT_SET_DEVICE_SNAP = "/openapi/setDeviceSnapEnhanced"
|
|
20
21
|
API_ENDPOINT_GET_IOT_DEVICE_PROPERTIES = "/openapi/getIotDeviceProperties"
|
|
21
22
|
API_ENDPOINT_SET_IOT_DEVICE_PROPERTIES = "/openapi/setIotDeviceProperties"
|
|
@@ -91,6 +92,7 @@ PARAM_STATUS = "status"
|
|
|
91
92
|
PARAM_CURRENT_OPTION = "current_option"
|
|
92
93
|
PARAM_MODES = "modes"
|
|
93
94
|
PARAM_OPTIONS = "options"
|
|
95
|
+
PARAM_SUPPORTED = "supported"
|
|
94
96
|
PARAM_CHANNELS = "channels"
|
|
95
97
|
PARAM_USED_BYTES = "usedBytes"
|
|
96
98
|
PARAM_TOTAL_BYTES = "totalBytes"
|
|
@@ -227,6 +229,53 @@ SWITCH_TYPE_ABILITY: dict[str, list[dict[str, Any]]] = {
|
|
|
227
229
|
"function_type": "smdHuman",
|
|
228
230
|
},
|
|
229
231
|
],
|
|
232
|
+
"frame_reverse": [
|
|
233
|
+
{
|
|
234
|
+
"ability": "FrameReverse",
|
|
235
|
+
"default": False,
|
|
236
|
+
"function_type": "frameReverse",
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"wide_dynamic": [
|
|
240
|
+
{
|
|
241
|
+
"ability": "WideDynamic",
|
|
242
|
+
"default": False,
|
|
243
|
+
"function_type": "wideDynamic",
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"smart_track": [
|
|
247
|
+
{
|
|
248
|
+
"ability": "SmartTrack",
|
|
249
|
+
"default": False,
|
|
250
|
+
"function_type": "smartTrack",
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
"play_sound": [
|
|
254
|
+
{
|
|
255
|
+
"ability": "PlaySound",
|
|
256
|
+
"default": False,
|
|
257
|
+
"function_type": "playSound",
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"linkage_siren": [
|
|
261
|
+
{
|
|
262
|
+
"ability": "LinkageSiren",
|
|
263
|
+
"default": False,
|
|
264
|
+
"function_type": "linkageSiren",
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"linkage_white_light": [
|
|
268
|
+
{
|
|
269
|
+
"ability": "WhiteLight",
|
|
270
|
+
"default": False,
|
|
271
|
+
"function_type": "linkageWhiteLight",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"ability": "ChnWhiteLight",
|
|
275
|
+
"default": False,
|
|
276
|
+
"function_type": "linkageWhiteLight",
|
|
277
|
+
},
|
|
278
|
+
],
|
|
230
279
|
}
|
|
231
280
|
|
|
232
281
|
SWITCH_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
@@ -238,13 +287,6 @@ SWITCH_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
|
238
287
|
"FKX9UYL4",
|
|
239
288
|
],
|
|
240
289
|
},
|
|
241
|
-
{
|
|
242
|
-
"ref": "305000",
|
|
243
|
-
"default": False,
|
|
244
|
-
"excepts": [
|
|
245
|
-
"FKX9UYL4",
|
|
246
|
-
],
|
|
247
|
-
},
|
|
248
290
|
{
|
|
249
291
|
"ref": "108800",
|
|
250
292
|
"default": False,
|
|
@@ -266,25 +308,13 @@ SWITCH_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
|
266
308
|
{
|
|
267
309
|
"ref": "14200",
|
|
268
310
|
"default": False,
|
|
269
|
-
}
|
|
270
|
-
{
|
|
271
|
-
"ref": "115300",
|
|
272
|
-
"default": False,
|
|
273
|
-
},
|
|
311
|
+
}
|
|
274
312
|
],
|
|
275
313
|
"audio_encode_control": [
|
|
276
314
|
{
|
|
277
315
|
"ref": "13900",
|
|
278
316
|
"default": False,
|
|
279
|
-
}
|
|
280
|
-
{
|
|
281
|
-
"ref": "104000",
|
|
282
|
-
"default": False,
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
"ref": "103800",
|
|
286
|
-
"default": False,
|
|
287
|
-
},
|
|
317
|
+
}
|
|
288
318
|
],
|
|
289
319
|
"header_detect": [
|
|
290
320
|
{
|
|
@@ -320,6 +350,48 @@ SWITCH_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
|
320
350
|
"default": False,
|
|
321
351
|
}
|
|
322
352
|
],
|
|
353
|
+
"pet_detect": [
|
|
354
|
+
{
|
|
355
|
+
"ref": "18300",
|
|
356
|
+
"default": False,
|
|
357
|
+
}
|
|
358
|
+
],
|
|
359
|
+
"frame_reverse": [
|
|
360
|
+
{
|
|
361
|
+
"ref": "13500",
|
|
362
|
+
"default": False,
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"wide_dynamic": [
|
|
366
|
+
{
|
|
367
|
+
"ref": "19400",
|
|
368
|
+
"default": False,
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"smart_track": [
|
|
372
|
+
{
|
|
373
|
+
"ref": "13300",
|
|
374
|
+
"default": False,
|
|
375
|
+
}
|
|
376
|
+
],
|
|
377
|
+
"play_sound": [
|
|
378
|
+
{
|
|
379
|
+
"ref": "14000",
|
|
380
|
+
"default": False,
|
|
381
|
+
}
|
|
382
|
+
],
|
|
383
|
+
"linkage_siren": [
|
|
384
|
+
{
|
|
385
|
+
"ref": "102000",
|
|
386
|
+
"default": False,
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
"linkage_white_light": [
|
|
390
|
+
{
|
|
391
|
+
"ref": "17300",
|
|
392
|
+
"default": False,
|
|
393
|
+
}
|
|
394
|
+
],
|
|
323
395
|
}
|
|
324
396
|
# Required capacity for various button types
|
|
325
397
|
BUTTON_TYPE_ABILITY: dict[str, list[str]] = {
|
|
@@ -441,14 +513,6 @@ SELECT_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
|
441
513
|
"value_type": "int",
|
|
442
514
|
},
|
|
443
515
|
],
|
|
444
|
-
"mode": [
|
|
445
|
-
{
|
|
446
|
-
"ref": "15200",
|
|
447
|
-
"default": "home",
|
|
448
|
-
"options": ["home", "away", "disarm"],
|
|
449
|
-
"value_type": "int",
|
|
450
|
-
}
|
|
451
|
-
],
|
|
452
516
|
"device_volume": [
|
|
453
517
|
{
|
|
454
518
|
"ref": "15400",
|
|
@@ -468,6 +532,14 @@ SELECT_TYPE_REF: dict[str, list[dict[str, Any]]] = {
|
|
|
468
532
|
}
|
|
469
533
|
],
|
|
470
534
|
}
|
|
535
|
+
ALARM_CONTROL_PANEL_REF: list[dict[str, Any]] = [
|
|
536
|
+
{
|
|
537
|
+
"ref": "15200",
|
|
538
|
+
"default": "home",
|
|
539
|
+
"supported": ["home", "away", "disarm"],
|
|
540
|
+
"value_type": "int",
|
|
541
|
+
}
|
|
542
|
+
]
|
|
471
543
|
# Required capacity for various sensor types
|
|
472
544
|
SENSOR_TYPE_ABILITY: dict[str, list[str]] = {
|
|
473
545
|
"storage_used": ["LocalStorage", "LocalStorageEnable"],
|
|
@@ -21,6 +21,7 @@ from .const import (
|
|
|
21
21
|
API_ENDPOINT_GET_IOT_DEVICE_DETAIL_INFO,
|
|
22
22
|
API_ENDPOINT_GET_IOT_DEVICE_PROPERTIES,
|
|
23
23
|
API_ENDPOINT_GET_PRODUCT_MODEL,
|
|
24
|
+
API_ENDPOINT_GET_STREAM_URL,
|
|
24
25
|
API_ENDPOINT_IOT_DEVICE_CONTROL,
|
|
25
26
|
API_ENDPOINT_LIST_DEVICE_DETAILS,
|
|
26
27
|
API_ENDPOINT_MODIFY_DEVICE_ALARM_STATUS,
|
|
@@ -321,6 +322,12 @@ class ImouDeviceManager:
|
|
|
321
322
|
return
|
|
322
323
|
self._event_maps[product_id] = _parse_event_ref_map(data)
|
|
323
324
|
|
|
325
|
+
def cached_event_map(self, product_id: str) -> dict[str, str]:
|
|
326
|
+
"""Return the cached events ref→identifier map, or {} if not loaded."""
|
|
327
|
+
if not product_id:
|
|
328
|
+
return {}
|
|
329
|
+
return dict(self._event_maps.get(product_id) or {})
|
|
330
|
+
|
|
324
331
|
async def async_resolve_event_identifier(
|
|
325
332
|
self, product_id: str, ref: str
|
|
326
333
|
) -> str | None:
|
|
@@ -334,9 +341,22 @@ class ImouDeviceManager:
|
|
|
334
341
|
return mapping.get(str(ref))
|
|
335
342
|
|
|
336
343
|
async def async_get_devices(
|
|
337
|
-
self,
|
|
344
|
+
self,
|
|
345
|
+
page: int = 1,
|
|
346
|
+
page_size: int = 10,
|
|
347
|
+
*,
|
|
348
|
+
fetch_ability_refs: bool | set[str] = True,
|
|
338
349
|
) -> list[ImouDevice]:
|
|
339
|
-
"""GET DEVICE LIST
|
|
350
|
+
"""GET DEVICE LIST.
|
|
351
|
+
|
|
352
|
+
``fetch_ability_refs`` controls the per-IoT ``getIotDeviceDetailInfo``
|
|
353
|
+
calls that resolve ability refs (needed to register entities, not to
|
|
354
|
+
notice that a device appeared or vanished):
|
|
355
|
+
|
|
356
|
+
- ``True`` (default): fetch for every IoT device on the page
|
|
357
|
+
- ``False``: skip every detail call (list-only discovery)
|
|
358
|
+
- a set of device ids: fetch only for those ids
|
|
359
|
+
"""
|
|
340
360
|
params = {
|
|
341
361
|
PARAM_PAGE: page,
|
|
342
362
|
PARAM_PAGE_SIZE: page_size,
|
|
@@ -396,19 +416,27 @@ class ImouDeviceManager:
|
|
|
396
416
|
iot_devices.append(imou_device)
|
|
397
417
|
devices.append(imou_device)
|
|
398
418
|
# Each iot device costs one getIotDeviceDetailInfo call; issue them together
|
|
399
|
-
# so listing N devices is one round trip instead of N serial ones
|
|
400
|
-
|
|
419
|
+
# so listing N devices is one round trip instead of N serial ones. Callers
|
|
420
|
+
# that only need the set of device keys (periodic rediscovery) pass
|
|
421
|
+
# fetch_ability_refs=False and skip this entirely.
|
|
422
|
+
if fetch_ability_refs is False:
|
|
423
|
+
to_fetch: list[ImouDevice] = []
|
|
424
|
+
elif fetch_ability_refs is True:
|
|
425
|
+
to_fetch = iot_devices
|
|
426
|
+
else:
|
|
427
|
+
to_fetch = [d for d in iot_devices if d.device_id in fetch_ability_refs]
|
|
428
|
+
if to_fetch:
|
|
401
429
|
# One accessory that is offline, rate limited, or answering 5xx must
|
|
402
430
|
# not cost the caller its whole account. That device keeps its
|
|
403
431
|
# "unknown" refs and comes back with the next listing.
|
|
404
432
|
results = await asyncio.gather(
|
|
405
433
|
*(
|
|
406
434
|
self._async_update_device_ability_refs(iot_device)
|
|
407
|
-
for iot_device in
|
|
435
|
+
for iot_device in to_fetch
|
|
408
436
|
),
|
|
409
437
|
return_exceptions=True,
|
|
410
438
|
)
|
|
411
|
-
for iot_device, result in zip(
|
|
439
|
+
for iot_device, result in zip(to_fetch, results, strict=True):
|
|
412
440
|
if isinstance(result, asyncio.CancelledError):
|
|
413
441
|
raise result
|
|
414
442
|
if isinstance(result, BaseException):
|
|
@@ -422,7 +450,13 @@ class ImouDeviceManager:
|
|
|
422
450
|
# that field the account total instead of this page's size, an account
|
|
423
451
|
# holding an exact multiple of page_size would page on forever.
|
|
424
452
|
if len(device_list) >= page_size:
|
|
425
|
-
devices.extend(
|
|
453
|
+
devices.extend(
|
|
454
|
+
await self.async_get_devices(
|
|
455
|
+
page + 1,
|
|
456
|
+
page_size,
|
|
457
|
+
fetch_ability_refs=fetch_ability_refs,
|
|
458
|
+
)
|
|
459
|
+
)
|
|
426
460
|
return devices
|
|
427
461
|
|
|
428
462
|
async def async_get_device_summaries(
|
|
@@ -576,6 +610,28 @@ class ImouDeviceManager:
|
|
|
576
610
|
API_ENDPOINT_GET_DEVICE_LIVE_INFO, params
|
|
577
611
|
)
|
|
578
612
|
|
|
613
|
+
async def async_get_rtsp_stream_url(
|
|
614
|
+
self,
|
|
615
|
+
device_id: str,
|
|
616
|
+
channel_id: str | None,
|
|
617
|
+
stream_id: int = 0,
|
|
618
|
+
product_id: str | None = None,
|
|
619
|
+
) -> dict[str, Any]:
|
|
620
|
+
"""Obtain a short-lived cloud RTSP URL (getStreamUrl).
|
|
621
|
+
|
|
622
|
+
``productId`` is only sent for IoT devices that have one.
|
|
623
|
+
"""
|
|
624
|
+
params: dict[str, Any] = {
|
|
625
|
+
PARAM_DEVICE_ID: device_id,
|
|
626
|
+
PARAM_CHANNEL_ID: channel_id,
|
|
627
|
+
PARAM_STREAM_ID: stream_id,
|
|
628
|
+
}
|
|
629
|
+
if product_id:
|
|
630
|
+
params[PARAM_PRODUCT_ID] = product_id
|
|
631
|
+
return await self._imou_api_client.async_request_api(
|
|
632
|
+
API_ENDPOINT_GET_STREAM_URL, params
|
|
633
|
+
)
|
|
634
|
+
|
|
579
635
|
async def async_get_device_snap(
|
|
580
636
|
self, device_id: str, channel_id: str | None
|
|
581
637
|
) -> dict[str, Any]:
|