mijiaAPI 1.3.2__tar.gz → 1.3.4__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,29 +1,33 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: mijiaAPI
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: A Python API for Xiaomi Mijia
5
- Home-page: https://github.com/Do1e/mijia-api
6
5
  License: GPLv3
7
6
  Author: Do1e
8
7
  Author-email: dpj.email@qq.com
9
- Requires-Python: >=3.12,<4.0
8
+ Requires-Python: >=3.9,<4.0
10
9
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
10
  Classifier: License :: Other/Proprietary License
12
11
  Classifier: Operating System :: OS Independent
13
12
  Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
14
16
  Classifier: Programming Language :: Python :: 3.12
15
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Dist: pillow (>=11.0.0,<12.0.0)
16
19
  Requires-Dist: qrcode (>=8.0,<9.0)
17
20
  Requires-Dist: requests (>=2.32.3,<3.0.0)
21
+ Project-URL: Homepage, https://github.com/Do1e/mijia-api
18
22
  Project-URL: Repository, https://github.com/Do1e/mijia-api
19
23
  Description-Content-Type: text/markdown
20
24
 
21
25
  # mijiaAPI
22
- 小米米家设备的api,可以使用代码直接控制米家设备的功能
26
+ 小米米家设备的api,可以使用代码直接控制米家设备的功能,[Github link](https://github.com/Do1e/mijia-api),[PyPI link](https://pypi.org/project/mijiaAPI/)。
23
27
 
24
28
  ## 安装
25
29
  ```bash
26
- python setup.py install
30
+ poetry install
27
31
  ```
28
32
  或者
29
33
  ```bash
@@ -1,9 +1,9 @@
1
1
  # mijiaAPI
2
- 小米米家设备的api,可以使用代码直接控制米家设备的功能
2
+ 小米米家设备的api,可以使用代码直接控制米家设备的功能,[Github link](https://github.com/Do1e/mijia-api),[PyPI link](https://pypi.org/project/mijiaAPI/)。
3
3
 
4
4
  ## 安装
5
5
  ```bash
6
- python setup.py install
6
+ poetry install
7
7
  ```
8
8
  或者
9
9
  ```bash
@@ -1,169 +1,169 @@
1
- from typing import Union
2
- import requests
3
- import requests.cookies
4
-
5
- from .utils import defaultUA, post_data, PostDataError
6
-
7
- class mijiaAPI(object):
8
- def __init__(self, auth_data: dict):
9
- if any(k not in auth_data for k in ['userId', 'deviceId', 'ssecurity', 'serviceToken']):
10
- raise Exception('Invalid authorize data')
11
- self.userId = auth_data['userId']
12
- self.ssecurity = auth_data['ssecurity']
13
- self.session = requests.Session()
14
- self.session.headers.update({
15
- 'User-Agent': defaultUA,
16
- 'x-xiaomi-protocal-flag-cli': 'PROTOCAL-HTTP2',
17
- 'Cookie': f'PassportDeviceId={auth_data["deviceId"]};'
18
- f'userId={auth_data["userId"]};'
19
- f'serviceToken={auth_data["serviceToken"]};',
20
- })
21
-
22
- @staticmethod
23
- def _post_process(data: dict) -> Union[list, bool]:
24
- if data['code'] != 0:
25
- raise Exception(f'Failed to get data, {data["message"]}')
26
- return data['result']
27
-
28
- @property
29
- def available(self) -> bool:
30
- """check if the API is available"""
31
- uri = '/home/device_list'
32
- data = {"getVirtualModel": False, "getHuamiDevices": 0}
33
- try:
34
- post_data(self.session, self.ssecurity, uri, data)
35
- return True
36
- except PostDataError:
37
- return False
38
-
39
- def get_devices_list(self) -> list:
40
- """get devices list
41
- mijiaAPI.get_devices_list() -> list
42
- -------
43
- @return
44
- dict, devices list
45
- """
46
- uri = '/home/device_list'
47
- data = {"getVirtualModel": False, "getHuamiDevices": 0}
48
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
49
-
50
- def get_homes_list(self) -> list:
51
- """get homes list
52
- mijiaAPI.get_homes_list() -> list
53
- -------
54
- @return
55
- list, homes list, including rooms
56
- """
57
- uri = '/v2/homeroom/gethome'
58
- data = {"fg": False, "fetch_share": True, "fetch_share_dev": True, "limit": 300, "app_ver": 7}
59
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
60
-
61
- def get_scenes_list(self, home_id: str) -> list:
62
- """get scenes list
63
- set it in Mi Home APP -> Add -> Manual controls
64
- mijiaAPI.get_scenes_list(home_id: str) -> list
65
- -------
66
- @param
67
- home_id: str, room id, get from get_homes_list
68
- -------
69
- @return
70
- list, scenes list
71
- """
72
- uri = '/appgateway/miot/appsceneservice/AppSceneService/GetSceneList'
73
- data = {"home_id": home_id}
74
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
75
-
76
- def run_scene(self, scene_id: str) -> bool:
77
- """run scene
78
- mijiaAPI.run_scene(scene_id: str) -> bool
79
- -------
80
- @param
81
- scene_id: str, scene id, get from get_scenes_list
82
- -------
83
- @return
84
- dict, result
85
- """
86
- uri = '/appgateway/miot/appsceneservice/AppSceneService/RunScene'
87
- data = {"scene_id": scene_id, "trigger_key": "user.click"}
88
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
89
-
90
- def get_consumable_items(self, home_id: str) -> list:
91
- """get consumable items
92
- mijiaAPI.get_consumable_items(did: str) -> list
93
- -------
94
- @param
95
- home_id: str, room id, get from get_homes_list
96
- -------
97
- @return
98
- list, consumable items
99
- """
100
- uri = '/v2/home/standard_consumable_items'
101
- data = {"home_id": int(home_id), "owner_id": self.userId}
102
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
103
-
104
- def get_devices_prop(self, data: list) -> list:
105
- """get devices properties
106
- mijiaAPI.get_devices_prop(data: list) -> list
107
- -------
108
- @param
109
- data: list of dict
110
- dict keys:
111
- - did: str, device id, get from get_devices_list
112
- - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
113
- - piid: str, property id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
114
- model yeelink.light.lamp4 as an example:
115
- [
116
- {"did": "1234567890", "siid": 2, "piid": 2}, # get the brightness
117
- {"did": "1234567890", "siid": 2, "piid": 3}, # get the color temperature
118
- ]
119
- -------
120
- @return
121
- list, device properties
122
- """
123
- uri = '/miotspec/prop/get'
124
- data = {"params": data}
125
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
126
-
127
- def set_devices_prop(self, data: list) -> list:
128
- """set devices properties
129
- mijiaAPI.set_devices_prop(data: list) -> list
130
- -------
131
- @param
132
- data: list of dict
133
- dict keys:
134
- - did: str, device id, get from get_devices_list
135
- - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
136
- - piid: str, property id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
137
- - value: str, value to set
138
- model yeelink.light.lamp4 as an example:
139
- [
140
- {"did": "1234567890", "siid": 2, "piid": 2, "value": 50} # set the brightness to 50%
141
- {"did": "1234567890", "siid": 2, "piid": 3, "value": 2700} # set the color temperature to 2700K
142
- ]
143
- -------
144
- @return
145
- dict, result
146
- """
147
- uri = '/miotspec/prop/set'
148
- data = {"params": data}
149
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
150
-
151
- def run_action(self, data: dict) -> dict:
152
- """run action
153
- mijiaAPI.run_action(data: dict) -> dict
154
- @param
155
- data: dict
156
- dict keys:
157
- - did: str, device id, get from get_devices_list
158
- - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
159
- - aiid: str, action id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
160
- - value: list, value to list
161
- model xiaomi.feeder.pi2001 as an example:
162
- {"did": "1234567890", "siid": 2, "aiid": 1, "value": [2]}, # Remote feeding (2 servings) of food
163
- -------
164
- @return
165
- dict, result
166
- """
167
- uri = '/miotspec/action'
168
- data = {"params": data}
169
- return self._post_process(post_data(self.session, self.ssecurity, uri, data))
1
+ from typing import Union
2
+ import requests
3
+ import requests.cookies
4
+
5
+ from .utils import defaultUA, post_data, PostDataError
6
+
7
+ class mijiaAPI(object):
8
+ def __init__(self, auth_data: dict):
9
+ if any(k not in auth_data for k in ['userId', 'deviceId', 'ssecurity', 'serviceToken']):
10
+ raise Exception('Invalid authorize data')
11
+ self.userId = auth_data['userId']
12
+ self.ssecurity = auth_data['ssecurity']
13
+ self.session = requests.Session()
14
+ self.session.headers.update({
15
+ 'User-Agent': defaultUA,
16
+ 'x-xiaomi-protocal-flag-cli': 'PROTOCAL-HTTP2',
17
+ 'Cookie': f'PassportDeviceId={auth_data["deviceId"]};'
18
+ f'userId={auth_data["userId"]};'
19
+ f'serviceToken={auth_data["serviceToken"]};',
20
+ })
21
+
22
+ @staticmethod
23
+ def _post_process(data: dict) -> Union[list, bool]:
24
+ if data['code'] != 0:
25
+ raise Exception(f'Failed to get data, {data["message"]}')
26
+ return data['result']
27
+
28
+ @property
29
+ def available(self) -> bool:
30
+ """check if the API is available"""
31
+ uri = '/home/device_list'
32
+ data = {"getVirtualModel": False, "getHuamiDevices": 0}
33
+ try:
34
+ post_data(self.session, self.ssecurity, uri, data)
35
+ return True
36
+ except PostDataError:
37
+ return False
38
+
39
+ def get_devices_list(self) -> list:
40
+ """get devices list
41
+ mijiaAPI.get_devices_list() -> list
42
+ -------
43
+ @return
44
+ dict, devices list
45
+ """
46
+ uri = '/home/device_list'
47
+ data = {"getVirtualModel": False, "getHuamiDevices": 0}
48
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
49
+
50
+ def get_homes_list(self) -> list:
51
+ """get homes list
52
+ mijiaAPI.get_homes_list() -> list
53
+ -------
54
+ @return
55
+ list, homes list, including rooms
56
+ """
57
+ uri = '/v2/homeroom/gethome'
58
+ data = {"fg": False, "fetch_share": True, "fetch_share_dev": True, "limit": 300, "app_ver": 7}
59
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
60
+
61
+ def get_scenes_list(self, home_id: str) -> list:
62
+ """get scenes list
63
+ set it in Mi Home APP -> Add -> Manual controls
64
+ mijiaAPI.get_scenes_list(home_id: str) -> list
65
+ -------
66
+ @param
67
+ home_id: str, room id, get from get_homes_list
68
+ -------
69
+ @return
70
+ list, scenes list
71
+ """
72
+ uri = '/appgateway/miot/appsceneservice/AppSceneService/GetSceneList'
73
+ data = {"home_id": home_id}
74
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
75
+
76
+ def run_scene(self, scene_id: str) -> bool:
77
+ """run scene
78
+ mijiaAPI.run_scene(scene_id: str) -> bool
79
+ -------
80
+ @param
81
+ scene_id: str, scene id, get from get_scenes_list
82
+ -------
83
+ @return
84
+ dict, result
85
+ """
86
+ uri = '/appgateway/miot/appsceneservice/AppSceneService/RunScene'
87
+ data = {"scene_id": scene_id, "trigger_key": "user.click"}
88
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
89
+
90
+ def get_consumable_items(self, home_id: str) -> list:
91
+ """get consumable items
92
+ mijiaAPI.get_consumable_items(did: str) -> list
93
+ -------
94
+ @param
95
+ home_id: str, room id, get from get_homes_list
96
+ -------
97
+ @return
98
+ list, consumable items
99
+ """
100
+ uri = '/v2/home/standard_consumable_items'
101
+ data = {"home_id": int(home_id), "owner_id": self.userId}
102
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
103
+
104
+ def get_devices_prop(self, data: list) -> list:
105
+ """get devices properties
106
+ mijiaAPI.get_devices_prop(data: list) -> list
107
+ -------
108
+ @param
109
+ data: list of dict
110
+ dict keys:
111
+ - did: str, device id, get from get_devices_list
112
+ - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
113
+ - piid: str, property id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
114
+ model yeelink.light.lamp4 as an example:
115
+ [
116
+ {"did": "1234567890", "siid": 2, "piid": 2}, # get the brightness
117
+ {"did": "1234567890", "siid": 2, "piid": 3}, # get the color temperature
118
+ ]
119
+ -------
120
+ @return
121
+ list, device properties
122
+ """
123
+ uri = '/miotspec/prop/get'
124
+ data = {"params": data}
125
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
126
+
127
+ def set_devices_prop(self, data: list) -> list:
128
+ """set devices properties
129
+ mijiaAPI.set_devices_prop(data: list) -> list
130
+ -------
131
+ @param
132
+ data: list of dict
133
+ dict keys:
134
+ - did: str, device id, get from get_devices_list
135
+ - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
136
+ - piid: str, property id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
137
+ - value: str, value to set
138
+ model yeelink.light.lamp4 as an example:
139
+ [
140
+ {"did": "1234567890", "siid": 2, "piid": 2, "value": 50} # set the brightness to 50%
141
+ {"did": "1234567890", "siid": 2, "piid": 3, "value": 2700} # set the color temperature to 2700K
142
+ ]
143
+ -------
144
+ @return
145
+ dict, result
146
+ """
147
+ uri = '/miotspec/prop/set'
148
+ data = {"params": data}
149
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
150
+
151
+ def run_action(self, data: dict) -> dict:
152
+ """run action
153
+ mijiaAPI.run_action(data: dict) -> dict
154
+ @param
155
+ data: dict
156
+ dict keys:
157
+ - did: str, device id, get from get_devices_list
158
+ - siid: str, service id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
159
+ - aiid: str, action id, get from https://home.miot-spec.com/spec/{model}, model from get_devices_list
160
+ - value: list, value to list
161
+ model xiaomi.feeder.pi2001 as an example:
162
+ {"did": "1234567890", "siid": 2, "aiid": 1, "value": [2]}, # Remote feeding (2 servings) of food
163
+ -------
164
+ @return
165
+ dict, result
166
+ """
167
+ uri = '/miotspec/action'
168
+ data = {"params": data}
169
+ return self._post_process(post_data(self.session, self.ssecurity, uri, data))
@@ -69,21 +69,21 @@ class mijiaDevices(object):
69
69
  if not isinstance(value, bool):
70
70
  raise ValueError(f'Invalid value for bool: {value}, should be True or False')
71
71
  elif prop.type in ['int', 'uint']:
72
- try:
73
- value = int(value)
74
- if prop.range:
75
- if value < prop.range[0] or value > prop.range[1]:
76
- raise ValueError(f'Value out of range: {value}, should be in range {prop.range}')
77
- except ValueError:
78
- raise ValueError(f'Invalid value for int: {value}, should be an integer')
72
+ value = int(value)
73
+ if prop.range:
74
+ if value < prop.range[0] or value > prop.range[1]:
75
+ raise ValueError(f'Value out of range: {value}, should be in range {prop.range[:2]}')
76
+ if len(prop.range) >= 3 and prop.range[2] != 1:
77
+ if (value - prop.range[0]) % prop.range[2] != 0:
78
+ raise ValueError(f'Invalid value: {value}, should be in range {prop.range[:2]} with step {prop.range[2]}')
79
79
  elif prop.type == 'float':
80
- try:
81
- value = float(value)
82
- if prop.range:
83
- if value < prop.range[0] or value > prop.range[1]:
84
- raise ValueError(f'Value out of range: {value}, should be in range {prop.range}')
85
- except ValueError:
86
- raise ValueError(f'Invalid value for float: {value}, should be a float')
80
+ value = float(value)
81
+ if prop.range:
82
+ if value < prop.range[0] or value > prop.range[1]:
83
+ raise ValueError(f'Value out of range: {value}, should be in range {prop.range[:2]}')
84
+ if len(prop.range) >= 3 and isinstance(prop.range[2], int):
85
+ if int(value - prop.range[0]) % prop.range[2] != 0:
86
+ raise ValueError(f'Invalid value: {value}, should be in range {prop.range[:2]} with step {prop.range[2]}')
87
87
  elif prop.type == 'string':
88
88
  if not isinstance(value, str):
89
89
  raise ValueError(f'Invalid value for string: {value}, should be a string')
@@ -166,6 +166,8 @@ def get_device_info(device_model: str) -> dict:
166
166
  result['actions'] = []
167
167
  services = content['props']['spec']['services']
168
168
 
169
+ properties_name = []
170
+ actions_name = []
169
171
  for siid in services:
170
172
  if 'properties' in services[siid]:
171
173
  for piid in services[siid]['properties']:
@@ -193,11 +195,17 @@ def get_device_info(device_model: str) -> dict:
193
195
  }
194
196
  }
195
197
  if item['range'] is not None:
196
- item['range'] = item['range'][:2]
198
+ item['range'] = item['range']
199
+ if item['name'] in properties_name:
200
+ item["name"] = f'{services[siid]['name']}-{item["name"]}'
201
+ properties_name.append(item['name'])
197
202
  result['properties'].append({k: None if v == 'none' else v for k, v in item.items()})
198
203
  if 'actions' in services[siid]:
199
204
  for aiid in services[siid]['actions']:
200
205
  act = services[siid]['actions'][aiid]
206
+ if act['name'] in actions_name:
207
+ act['name'] = f'{services[siid]["name"]}-{act["name"]}'
208
+ actions_name.append(act['name'])
201
209
  result['actions'].append({
202
210
  'name': act['name'],
203
211
  'description': act['description'],
@@ -1,6 +1,6 @@
1
- sid = 'xiaomiio'
2
- msgURL = 'https://account.xiaomi.com/pass/serviceLogin?sid=%s&_json=true' % sid
3
- loginURL = 'https://account.xiaomi.com/pass/serviceLoginAuth2'
4
- qrURL = 'https://account.xiaomi.com/longPolling/loginUrl'
5
- apiURL = 'https://api.io.mi.com/app'
6
- deviceURL = 'https://home.miot-spec.com/spec/'
1
+ sid = 'xiaomiio'
2
+ msgURL = 'https://account.xiaomi.com/pass/serviceLogin?sid=%s&_json=true' % sid
3
+ loginURL = 'https://account.xiaomi.com/pass/serviceLoginAuth2'
4
+ qrURL = 'https://account.xiaomi.com/longPolling/loginUrl'
5
+ apiURL = 'https://api.io.mi.com/app'
6
+ deviceURL = 'https://home.miot-spec.com/spec/'
@@ -1,43 +1,43 @@
1
- import base64
2
- from hashlib import sha256
3
- import hmac
4
- import random
5
- import string
6
-
7
- import requests
8
-
9
- from .urls import apiURL
10
-
11
- defaultUA = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36 Edg/126.0.0.0'
12
-
13
- class PostDataError(Exception):
14
- def __init__(self, code: int, message: str):
15
- self.code = code
16
- self.message = message
17
- super().__init__(f'Error code: {code}, message: {message}')
18
-
19
- def _generate_signed_nonce(secret: str, nonce: str) -> str:
20
- sha = sha256()
21
- sha.update(base64.b64decode(secret))
22
- sha.update(base64.b64decode(nonce))
23
- return base64.b64encode(sha.digest()).decode()
24
-
25
-
26
- def _generate_signature(uri: str, signedNonce: str, nonce: str, data: str) -> str:
27
- sign = '&'.join([uri, signedNonce, nonce, f'data={data}'])
28
- mac = hmac.new(base64.b64decode(signedNonce), digestmod='sha256')
29
- mac.update(sign.encode())
30
- return base64.b64encode(mac.digest()).decode()
31
-
32
-
33
- def post_data(session: requests.Session, ssecurity: str, uri: str, data: dict) -> dict:
34
- data = str(data).replace("'", '"').replace('True', 'true').replace('False', 'false')
35
- nonce = ''.join(random.sample(string.digits + string.ascii_letters, 16))
36
- signed_nonce = _generate_signed_nonce(ssecurity, nonce)
37
- signature = _generate_signature(uri, signed_nonce, nonce, data)
38
- post_data = {'_nonce': nonce, 'data': data, 'signature': signature}
39
- ret = session.post(apiURL + uri, data=post_data)
40
- if ret.status_code != 200:
41
- raise PostDataError(ret.status_code, f'Failed to post data, {ret.text}')
42
- ret_data = ret.json()
43
- return ret_data
1
+ import base64
2
+ from hashlib import sha256
3
+ import hmac
4
+ import random
5
+ import string
6
+
7
+ import requests
8
+
9
+ from .urls import apiURL
10
+
11
+ defaultUA = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36 Edg/126.0.0.0'
12
+
13
+ class PostDataError(Exception):
14
+ def __init__(self, code: int, message: str):
15
+ self.code = code
16
+ self.message = message
17
+ super().__init__(f'Error code: {code}, message: {message}')
18
+
19
+ def _generate_signed_nonce(secret: str, nonce: str) -> str:
20
+ sha = sha256()
21
+ sha.update(base64.b64decode(secret))
22
+ sha.update(base64.b64decode(nonce))
23
+ return base64.b64encode(sha.digest()).decode()
24
+
25
+
26
+ def _generate_signature(uri: str, signedNonce: str, nonce: str, data: str) -> str:
27
+ sign = '&'.join([uri, signedNonce, nonce, f'data={data}'])
28
+ mac = hmac.new(base64.b64decode(signedNonce), digestmod='sha256')
29
+ mac.update(sign.encode())
30
+ return base64.b64encode(mac.digest()).decode()
31
+
32
+
33
+ def post_data(session: requests.Session, ssecurity: str, uri: str, data: dict) -> dict:
34
+ data = str(data).replace("'", '"').replace('True', 'true').replace('False', 'false')
35
+ nonce = ''.join(random.sample(string.digits + string.ascii_letters, 16))
36
+ signed_nonce = _generate_signed_nonce(ssecurity, nonce)
37
+ signature = _generate_signature(uri, signed_nonce, nonce, data)
38
+ post_data = {'_nonce': nonce, 'data': data, 'signature': signature}
39
+ ret = session.post(apiURL + uri, data=post_data)
40
+ if ret.status_code != 200:
41
+ raise PostDataError(ret.status_code, f'Failed to post data, {ret.text}')
42
+ ret_data = ret.json()
43
+ return ret_data
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mijiaAPI"
3
- version = "1.3.2"
3
+ version = "1.3.4"
4
4
  description = "A Python API for Xiaomi Mijia"
5
5
  authors = ["Do1e <dpj.email@qq.com>"]
6
6
  license = "GPLv3"
@@ -17,9 +17,10 @@ classifiers = [
17
17
  ]
18
18
 
19
19
  [tool.poetry.dependencies]
20
- python = "^3.12"
20
+ python = ">=3.9,<4.0"
21
21
  requests = "^2.32.3"
22
22
  qrcode = "^8.0"
23
+ pillow = "^11.0.0"
23
24
 
24
25
  [tool.poetry-dynamic-versioning]
25
26
  enable = false
File without changes
File without changes
File without changes