mijiaAPI 1.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mijiaAPI
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A Python API for Xiaomi Mijia
5
5
  License: GPLv3
6
6
  Author: Do1e
@@ -167,9 +167,10 @@ current_temp = device.color_temperature # 获取色温
167
167
  ```
168
168
  > python -m mijiaAPI --help
169
169
  > mijiaAPI --help
170
- usage: __main__.py [-h] [-p AUTH_PATH] [-l] [--list_homes] [--list_scenes] [--list_consumable_items]
171
- [--run_scene SCENE_ID/SCENE_NAME [SCENE_ID/SCENE_NAME ...]] [--get_device_info DEVICE_MODEL]
172
- {get,set} ...
170
+ usage: mijiaAPI [-h] [-p AUTH_PATH] [-l] [--list_homes] [--list_scenes] [--list_consumable_items]
171
+ [--run_scene SCENE_ID/SCENE_NAME [SCENE_ID/SCENE_NAME ...]] [--get_device_info DEVICE_MODEL] [--run PROMPT]
172
+ [--wifispeaker_name WIFISPEAKER_NAME] [--quiet]
173
+ {get,set} ...
173
174
 
174
175
  Mijia API CLI
175
176
 
@@ -191,6 +192,10 @@ options:
191
192
  运行场景,指定场景ID或名称
192
193
  --get_device_info DEVICE_MODEL
193
194
  获取设备信息,指定设备model,先使用 --list_devices 获取
195
+ --run PROMPT 使用自然语言描述你的需求,如果你有小爱音箱的话
196
+ --wifispeaker_name WIFISPEAKER_NAME
197
+ 指定小爱音箱名称,默认是获取到的第一个小爱音箱
198
+ --quiet 小爱音箱静默执行
194
199
  ```
195
200
 
196
201
  ```
@@ -222,6 +227,27 @@ options:
222
227
  --value VALUE 需要设定的属性值
223
228
  ```
224
229
 
230
+ 或者直接使用`uvx`忽略安装步骤:
231
+
232
+ ```bash
233
+ uvx mijiaAPI --help
234
+ ```
235
+
236
+ #### 示例:
237
+
238
+ ```bash
239
+ mijiaAPI -l # 列出所有米家设备
240
+ mijiaAPI --list_homes # 列出家庭列表
241
+ mijiaAPI --list_scenes # 列出场景列表
242
+ mijiaAPI --list_consumable_items # 列出耗材列表
243
+ mijiaAPI --run_scene SCENE_ID/SCENE_NAME # 运行场景,指定场景ID或名称
244
+ mijiaAPI --get_device_info DEVICE_MODEL # 获取设备信息,指定设备model,先使用 --list_devices 获取
245
+ mijiaAPI get --dev_name DEV_NAME --prop_name PROP_NAME # 获取设备属性
246
+ mijiaAPI set --dev_name DEV_NAME --prop_name PROP_NAME --value VALUE # 设置设备属性
247
+ mijiaAPI --run 明天天气如何
248
+ mijiaAPI --run 打开台灯并将亮度调至最大 --quiet
249
+ ```
250
+
225
251
  ## 致谢
226
252
 
227
253
  * [janzlan/mijia-api](https://gitee.com/janzlan/mijia-api/tree/master)
@@ -143,9 +143,10 @@ current_temp = device.color_temperature # 获取色温
143
143
  ```
144
144
  > python -m mijiaAPI --help
145
145
  > mijiaAPI --help
146
- usage: __main__.py [-h] [-p AUTH_PATH] [-l] [--list_homes] [--list_scenes] [--list_consumable_items]
147
- [--run_scene SCENE_ID/SCENE_NAME [SCENE_ID/SCENE_NAME ...]] [--get_device_info DEVICE_MODEL]
148
- {get,set} ...
146
+ usage: mijiaAPI [-h] [-p AUTH_PATH] [-l] [--list_homes] [--list_scenes] [--list_consumable_items]
147
+ [--run_scene SCENE_ID/SCENE_NAME [SCENE_ID/SCENE_NAME ...]] [--get_device_info DEVICE_MODEL] [--run PROMPT]
148
+ [--wifispeaker_name WIFISPEAKER_NAME] [--quiet]
149
+ {get,set} ...
149
150
 
150
151
  Mijia API CLI
151
152
 
@@ -167,6 +168,10 @@ options:
167
168
  运行场景,指定场景ID或名称
168
169
  --get_device_info DEVICE_MODEL
169
170
  获取设备信息,指定设备model,先使用 --list_devices 获取
171
+ --run PROMPT 使用自然语言描述你的需求,如果你有小爱音箱的话
172
+ --wifispeaker_name WIFISPEAKER_NAME
173
+ 指定小爱音箱名称,默认是获取到的第一个小爱音箱
174
+ --quiet 小爱音箱静默执行
170
175
  ```
171
176
 
172
177
  ```
@@ -198,6 +203,27 @@ options:
198
203
  --value VALUE 需要设定的属性值
199
204
  ```
200
205
 
206
+ 或者直接使用`uvx`忽略安装步骤:
207
+
208
+ ```bash
209
+ uvx mijiaAPI --help
210
+ ```
211
+
212
+ #### 示例:
213
+
214
+ ```bash
215
+ mijiaAPI -l # 列出所有米家设备
216
+ mijiaAPI --list_homes # 列出家庭列表
217
+ mijiaAPI --list_scenes # 列出场景列表
218
+ mijiaAPI --list_consumable_items # 列出耗材列表
219
+ mijiaAPI --run_scene SCENE_ID/SCENE_NAME # 运行场景,指定场景ID或名称
220
+ mijiaAPI --get_device_info DEVICE_MODEL # 获取设备信息,指定设备model,先使用 --list_devices 获取
221
+ mijiaAPI get --dev_name DEV_NAME --prop_name PROP_NAME # 获取设备属性
222
+ mijiaAPI set --dev_name DEV_NAME --prop_name PROP_NAME --value VALUE # 设置设备属性
223
+ mijiaAPI --run 明天天气如何
224
+ mijiaAPI --run 打开台灯并将亮度调至最大 --quiet
225
+ ```
226
+
201
227
  ## 致谢
202
228
 
203
229
  * [janzlan/mijia-api](https://gitee.com/janzlan/mijia-api/tree/master)
@@ -51,6 +51,23 @@ def parse_args(args):
51
51
  help="获取设备信息,指定设备model,先使用 --list_devices 获取",
52
52
  metavar='DEVICE_MODEL',
53
53
  )
54
+ parser.add_argument(
55
+ '--run',
56
+ type=str,
57
+ help="使用自然语言描述你的需求,如果你有小爱音箱的话",
58
+ metavar='PROMPT',
59
+ )
60
+ parser.add_argument(
61
+ '--wifispeaker_name',
62
+ type=str,
63
+ help="指定小爱音箱名称,默认是获取到的第一个小爱音箱",
64
+ default=None,
65
+ )
66
+ parser.add_argument(
67
+ '--quiet',
68
+ action='store_true',
69
+ help="小爱音箱静默执行",
70
+ )
54
71
 
55
72
  get = subparsers.add_parser(
56
73
  'get',
@@ -273,6 +290,20 @@ def main(args):
273
290
  if args.get_device_info:
274
291
  device_info = get_device_info(args.get_device_info)
275
292
  print(json.dumps(device_info, indent=2, ensure_ascii=False))
293
+ if args.run:
294
+ if device_mapping is None:
295
+ device_mapping = get_devices_list(api, verbose=False)
296
+ if args.wifispeaker_name is None:
297
+ wifispeaker = None
298
+ for device in device_mapping.values():
299
+ if 'xiaomi.wifispeaker' in device['model']:
300
+ wifispeaker = mijiaDevices(api, dev_name=device['name'])
301
+ break
302
+ if wifispeaker is None:
303
+ raise ValueError("No wifispeaker found")
304
+ else:
305
+ wifispeaker = mijiaDevices(api, dev_name=args.wifispeaker_name)
306
+ wifispeaker.run_action('execute-text-directive', _in=[args.run, args.quiet])
276
307
  if hasattr(args, 'func') and args.func is not None:
277
308
  if args.func == 'get':
278
309
  get(args)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mijiaAPI"
3
- version = "1.4.0"
3
+ version = "1.4.1"
4
4
  description = "A Python API for Xiaomi Mijia"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9,<4.0"
@@ -15,7 +15,7 @@ mijiaAPI = "mijiaAPI.__main__:cli"
15
15
 
16
16
  [tool.poetry]
17
17
  name = "mijiaAPI"
18
- version = "1.4.0"
18
+ version = "1.4.1"
19
19
  description = "A Python API for Xiaomi Mijia"
20
20
  authors = ["Do1e <dpj.email@qq.com>"]
21
21
  license = "GPLv3"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes