pyimouapi 1.2.5__tar.gz → 1.2.7__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.
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyimouapi
3
+ Version: 1.2.7
4
+ Summary: A package for imou open api
5
+ Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
+ Author: Imou-OpenPlatform
7
+ Author-email: cloud_openteam_service@imou.com
8
+ License: MIT
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: aiohttp<4.0,>=3.11.9
17
+ Requires-Dist: simpleeval>=1.0.3
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # pyimouapi
31
+
32
+ Async Python client for the **Imou Open Platform** cloud APIs. Built on **aiohttp**, it handles authentication and requests, and exposes device/channel helpers plus higher-level types for integrations (for example Home Assistant).
33
+
34
+ - **Repository:** [Imou-OpenPlatform/Py-Imou-Open-Api](https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api)
35
+ - **Version:** Same as `setup.py` / PyPI (`pyimouapi.__version__`)
36
+ - **Python:** `>= 3.11`
37
+
38
+ ## Package layout
39
+
40
+ | Module | Role |
41
+ |--------|------|
42
+ | `pyimouapi.openapi` | `ImouOpenApiClient` — auth, signing, token lifecycle, HTTP calls |
43
+ | `pyimouapi.device` | `ImouDeviceManager`, `ImouDevice`, `ImouChannel` — listing, PTZ, alarms, storage, and related endpoints |
44
+ | `pyimouapi.ha_device` | `ImouHaDeviceManager`, `ImouHaDevice`, … — aggregated “device model” helpers for automation stacks |
45
+ | `pyimouapi.exceptions` | `ImouException` and typed errors (connect, request, invalid credentials, …) |
46
+
47
+ The top-level `pyimouapi` package re-exports common symbols. Import submodules directly when needed, for example `from pyimouapi.ha_device import ImouHaDeviceManager`.
48
+
49
+ ## Dependencies
50
+
51
+ As declared in `setup.py` / `requirements.txt`:
52
+
53
+ - `aiohttp>=3.11.9,<4.0`
54
+ - `simpleeval>=1.0.3`
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ pip install pyimouapi
60
+ ```
61
+
62
+ From a checkout:
63
+
64
+ ```bash
65
+ pip install .
66
+ ```
67
+
68
+ ## Quick example (async)
69
+
70
+ ```python
71
+ from pyimouapi.openapi import ImouOpenApiClient
72
+
73
+ # host: Imou Open Platform gateway, e.g. openapi-sg.easy4ip.com
74
+ client = ImouOpenApiClient("your_app_id", "your_app_secret", "openapi-sg.easy4ip.com")
75
+ await client.async_get_token()
76
+ # Use the client with pyimouapi.device.ImouDeviceManager for device operations
77
+ ```
78
+
79
+ ## License
80
+
81
+ MIT — see `LICENSE` in this repository.
@@ -0,0 +1,52 @@
1
+ # pyimouapi
2
+
3
+ Async Python client for the **Imou Open Platform** cloud APIs. Built on **aiohttp**, it handles authentication and requests, and exposes device/channel helpers plus higher-level types for integrations (for example Home Assistant).
4
+
5
+ - **Repository:** [Imou-OpenPlatform/Py-Imou-Open-Api](https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api)
6
+ - **Version:** Same as `setup.py` / PyPI (`pyimouapi.__version__`)
7
+ - **Python:** `>= 3.11`
8
+
9
+ ## Package layout
10
+
11
+ | Module | Role |
12
+ |--------|------|
13
+ | `pyimouapi.openapi` | `ImouOpenApiClient` — auth, signing, token lifecycle, HTTP calls |
14
+ | `pyimouapi.device` | `ImouDeviceManager`, `ImouDevice`, `ImouChannel` — listing, PTZ, alarms, storage, and related endpoints |
15
+ | `pyimouapi.ha_device` | `ImouHaDeviceManager`, `ImouHaDevice`, … — aggregated “device model” helpers for automation stacks |
16
+ | `pyimouapi.exceptions` | `ImouException` and typed errors (connect, request, invalid credentials, …) |
17
+
18
+ The top-level `pyimouapi` package re-exports common symbols. Import submodules directly when needed, for example `from pyimouapi.ha_device import ImouHaDeviceManager`.
19
+
20
+ ## Dependencies
21
+
22
+ As declared in `setup.py` / `requirements.txt`:
23
+
24
+ - `aiohttp>=3.11.9,<4.0`
25
+ - `simpleeval>=1.0.3`
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install pyimouapi
31
+ ```
32
+
33
+ From a checkout:
34
+
35
+ ```bash
36
+ pip install .
37
+ ```
38
+
39
+ ## Quick example (async)
40
+
41
+ ```python
42
+ from pyimouapi.openapi import ImouOpenApiClient
43
+
44
+ # host: Imou Open Platform gateway, e.g. openapi-sg.easy4ip.com
45
+ client = ImouOpenApiClient("your_app_id", "your_app_secret", "openapi-sg.easy4ip.com")
46
+ await client.async_get_token()
47
+ # Use the client with pyimouapi.device.ImouDeviceManager for device operations
48
+ ```
49
+
50
+ ## License
51
+
52
+ MIT — see `LICENSE` in this repository.
@@ -1,4 +1,4 @@
1
- __version__ = "1.2.5"
1
+ __version__ = "1.2.7"
2
2
 
3
3
  from .device import ImouDeviceManager, ImouDevice, ImouChannel
4
4
  from .exceptions import (
@@ -413,7 +413,15 @@ SENSOR_TYPE_REF = {
413
413
  "expression": "('e1' if data['14603']==0 else 'e2') if data['14603'] != 1 else int(data['14602'] / data['14601'] * 100)",
414
414
  }
415
415
  ],
416
- "battery": [{"ref": "11600", "default": "15", "ref_type": "properties"}],
416
+ "battery": [
417
+ {"ref": "11600", "default": "15", "ref_type": "properties"},
418
+ {
419
+ "ref": "106200",
420
+ "default": "0",
421
+ "ref_type": "properties",
422
+ "expression": "battery_106200(data)",
423
+ },
424
+ ],
417
425
  "temperature_current": [
418
426
  {"ref": "16000", "default": "10", "ref_type": "properties"}
419
427
  ],
@@ -69,6 +69,53 @@ from simpleeval import SimpleEval
69
69
 
70
70
  _LOGGER: logging.Logger = logging.getLogger(__package__)
71
71
 
72
+
73
+ def _battery_level_from_106200_list(data) -> int:
74
+ """解析 ref 106200 电量属性: [{"106202": 电池类型, "106203": 电量}, ...]。
75
+ 多条时取 106202==0 的 106203;仅一条时取该条的 106203。
76
+ 键均为字符串。
77
+ """
78
+ if not isinstance(data, list) or not data:
79
+ return 0
80
+
81
+ k_type, k_level = "106202", "106203"
82
+
83
+ def _to_int(v):
84
+ if v is None:
85
+ return None
86
+ if isinstance(v, bool):
87
+ return int(v)
88
+ if isinstance(v, int):
89
+ return v
90
+ if isinstance(v, float):
91
+ return int(v)
92
+ try:
93
+ return int(str(v).strip())
94
+ except ValueError:
95
+ return None
96
+
97
+ if len(data) == 1:
98
+ row = data[0]
99
+ if not isinstance(row, dict):
100
+ return 0
101
+ level = _to_int(row.get(k_level))
102
+ return level if level is not None else 0
103
+
104
+ for row in data:
105
+ if not isinstance(row, dict):
106
+ continue
107
+ if _to_int(row.get(k_type)) == 0:
108
+ level = _to_int(row.get(k_level))
109
+ if level is not None:
110
+ return level
111
+
112
+ row0 = data[0]
113
+ if not isinstance(row0, dict):
114
+ return 0
115
+ level = _to_int(row0.get(k_level))
116
+ return level if level is not None else 0
117
+
118
+
72
119
  NUMBER_TYPE = [
73
120
  PARAM_STORAGE_USED,
74
121
  PARAM_TEMPERATURE_CURRENT,
@@ -412,9 +459,15 @@ class ImouHaDeviceManager(object):
412
459
  return devices
413
460
 
414
461
  @staticmethod
415
- def get_expression_value(expression: str, data: dict):
462
+ def get_expression_value(expression: str, data):
416
463
  s = SimpleEval(
417
- names={"data": data}, functions={"round": round, "int": int, "str": str}
464
+ names={"data": data},
465
+ functions={
466
+ "round": round,
467
+ "int": int,
468
+ "str": str,
469
+ "battery_106200": _battery_level_from_106200_list,
470
+ },
418
471
  )
419
472
  return s.eval(expression)
420
473
 
@@ -1040,7 +1093,7 @@ class ImouHaDeviceManager(object):
1040
1093
  device_id, device.channel_id, device.product_id, [value[PARAM_REF]]
1041
1094
  )
1042
1095
  data = result[PARAM_PROPERTIES][value[PARAM_REF]]
1043
- if value.get(PARAM_EXPRESSION) and isinstance(data, dict):
1096
+ if value.get(PARAM_EXPRESSION) and isinstance(data, (dict, list)):
1044
1097
  state = self.get_expression_value(value[PARAM_EXPRESSION], data)
1045
1098
  else:
1046
1099
  state = data
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyimouapi
3
+ Version: 1.2.7
4
+ Summary: A package for imou open api
5
+ Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
+ Author: Imou-OpenPlatform
7
+ Author-email: cloud_openteam_service@imou.com
8
+ License: MIT
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: aiohttp<4.0,>=3.11.9
17
+ Requires-Dist: simpleeval>=1.0.3
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # pyimouapi
31
+
32
+ Async Python client for the **Imou Open Platform** cloud APIs. Built on **aiohttp**, it handles authentication and requests, and exposes device/channel helpers plus higher-level types for integrations (for example Home Assistant).
33
+
34
+ - **Repository:** [Imou-OpenPlatform/Py-Imou-Open-Api](https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api)
35
+ - **Version:** Same as `setup.py` / PyPI (`pyimouapi.__version__`)
36
+ - **Python:** `>= 3.11`
37
+
38
+ ## Package layout
39
+
40
+ | Module | Role |
41
+ |--------|------|
42
+ | `pyimouapi.openapi` | `ImouOpenApiClient` — auth, signing, token lifecycle, HTTP calls |
43
+ | `pyimouapi.device` | `ImouDeviceManager`, `ImouDevice`, `ImouChannel` — listing, PTZ, alarms, storage, and related endpoints |
44
+ | `pyimouapi.ha_device` | `ImouHaDeviceManager`, `ImouHaDevice`, … — aggregated “device model” helpers for automation stacks |
45
+ | `pyimouapi.exceptions` | `ImouException` and typed errors (connect, request, invalid credentials, …) |
46
+
47
+ The top-level `pyimouapi` package re-exports common symbols. Import submodules directly when needed, for example `from pyimouapi.ha_device import ImouHaDeviceManager`.
48
+
49
+ ## Dependencies
50
+
51
+ As declared in `setup.py` / `requirements.txt`:
52
+
53
+ - `aiohttp>=3.11.9,<4.0`
54
+ - `simpleeval>=1.0.3`
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ pip install pyimouapi
60
+ ```
61
+
62
+ From a checkout:
63
+
64
+ ```bash
65
+ pip install .
66
+ ```
67
+
68
+ ## Quick example (async)
69
+
70
+ ```python
71
+ from pyimouapi.openapi import ImouOpenApiClient
72
+
73
+ # host: Imou Open Platform gateway, e.g. openapi-sg.easy4ip.com
74
+ client = ImouOpenApiClient("your_app_id", "your_app_secret", "openapi-sg.easy4ip.com")
75
+ await client.async_get_token()
76
+ # Use the client with pyimouapi.device.ImouDeviceManager for device operations
77
+ ```
78
+
79
+ ## License
80
+
81
+ MIT — see `LICENSE` in this repository.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pyimouapi",
5
- version="1.2.5",
5
+ version="1.2.7",
6
6
  packages=find_packages(),
7
7
  python_requires=">=3.11",
8
8
  install_requires=[
pyimouapi-1.2.5/PKG-INFO DELETED
@@ -1,34 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyimouapi
3
- Version: 1.2.5
4
- Summary: A package for imou open api
5
- Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
- Author: Imou-OpenPlatform
7
- Author-email: cloud_openteam_service@imou.com
8
- License: MIT
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Topic :: Software Development :: Libraries
13
- Requires-Python: >=3.11
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: aiohttp<4.0,>=3.11.9
17
- Requires-Dist: simpleeval>=1.0.3
18
- Dynamic: author
19
- Dynamic: author-email
20
- Dynamic: classifier
21
- Dynamic: description
22
- Dynamic: description-content-type
23
- Dynamic: home-page
24
- Dynamic: license
25
- Dynamic: license-file
26
- Dynamic: requires-dist
27
- Dynamic: requires-python
28
- Dynamic: summary
29
-
30
- ## 打包
31
- python setup.py sdist bdist_wheel
32
-
33
- ## 上传
34
- twine upload dist/*
pyimouapi-1.2.5/README.md DELETED
@@ -1,5 +0,0 @@
1
- ## 打包
2
- python setup.py sdist bdist_wheel
3
-
4
- ## 上传
5
- twine upload dist/*
@@ -1,34 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyimouapi
3
- Version: 1.2.5
4
- Summary: A package for imou open api
5
- Home-page: https://github.com/Imou-OpenPlatform/Py-Imou-Open-Api
6
- Author: Imou-OpenPlatform
7
- Author-email: cloud_openteam_service@imou.com
8
- License: MIT
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Topic :: Software Development :: Libraries
13
- Requires-Python: >=3.11
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: aiohttp<4.0,>=3.11.9
17
- Requires-Dist: simpleeval>=1.0.3
18
- Dynamic: author
19
- Dynamic: author-email
20
- Dynamic: classifier
21
- Dynamic: description
22
- Dynamic: description-content-type
23
- Dynamic: home-page
24
- Dynamic: license
25
- Dynamic: license-file
26
- Dynamic: requires-dist
27
- Dynamic: requires-python
28
- Dynamic: summary
29
-
30
- ## 打包
31
- python setup.py sdist bdist_wheel
32
-
33
- ## 上传
34
- twine upload dist/*
File without changes
File without changes
File without changes
File without changes