1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
%global _empty_manifest_terminate_build 0
Name: python-sharkiqpy
Version: 0.1.9
Release: 1
Summary: Python API for Shark IQ robots
License: MIT
URL: https://github.com/ajmarks/sharkiq
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/28/44/9a1737dfff203762c8d13924564ff954d624a1d01acbccf207691b7ae813/sharkiqpy-0.1.9.tar.gz
BuildArch: noarch
Requires: python3-aiohttp
Requires: python3-requests
%description
# sharkiqpy
Unofficial SDK for Shark IQ robot vacuums, designed primarily to support an integration for [Home Assistant](https://www.home-assistant.io/).
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.
```bash
pip install sharkiqpy
```
## Usage
### Simple Operation
```python
from sharkiqpy import get_ayla_api, OperatingModes, Properties, PowerModes
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
ayla_api = get_ayla_api(USERNAME, PASSWORD)
ayla_api.sign_in()
shark_vacs = ayla_api.get_devices()
shark = shark_vacs[0]
shark.update()
shark.set_operating_mode(OperatingModes.START)
shark.return_to_base()
```
### Async operation
```python
import asyncio
from sharkiqpy import get_ayla_api, OperatingModes, SharkIqVacuum
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
async def main(ayla_api) -> SharkIqVacuum:
await ayla_api.async_sign_in()
shark_vacs = await ayla_api.async_get_devices()
shark = shark_vacs[0]
await shark.async_update()
await shark.async_find_device()
await shark.async_set_operating_mode(OperatingModes.START)
return shark
ayla_api = get_ayla_api(USERNAME, PASSWORD)
shark = asyncio.run(main(ayla_api))
```
## Documentation
### `get_ayla_api(username, password, websession=None)`
Returns and `AylaApi` object to interact with the Ayla Networks Device API conrolling the Shark IQ robot, with the `app_id` and `app_secret` parameters set for the Shark IQ robot.
### `class AylaAPI(username, password, app_id, app_secret, websession)`
Class for interacting with the Ayla Networks Device API underlying the Shark IQ controls.
* `username: str`
* `password: str`
* `app_id: str`
* `app_secret: str`
* `websession: Optional[aiohttp.ClientSession] = None` Optional `aiohttp.ClientSession` to use for async calls. If
one is not provided, a new `aiohttp.ClientSession` will be created at the first async call.
#### Methods
* `get_devices()`/`async_get_devices()` Get a list of `SharkIqVacuum`s for every device found in `list_devices()`
* `list_devices()`/`async_list_devices()` Get a list of known device description `dict`s
* `refesh_auth()`/`async_refesh_auth()` Refresh the authentication token
* `request(method, url, headers = None, auto_refresh = True, **kwargs)`/`async_request(...)` Submit an HTTP request to
the Ayla networks API with the auth header
* `method: str` An HTTP method, usually `'get'` or `'post'`
* `url: str`
* `headers: Optional[Dict] = None` Optional `dict` of HTTP headers besides the auth header, which is included
automatically
* `auto_refresh: bool = True` If `True`, automatically call `refesh_auth()`/`async_refesh_auth()` if the auth token
is near expiration
* `**kwargs` Passed on to `requests.request` or `aiohttp.ClientSession.request`
* `sign_in()`/`async_sign_in()` Authenticate
* `sign_out()`/`async_sign_out()` Sign out
### `class SharkIqRobot(ayla_api, device_dct)`
Primary API for interacting with Shark IQ vacuums
* `ayla_api: AylaApi` An `AylaApi` with an authenticated connection
* `device_dct: Dict` A `dict` describing the device, usually obtained from `AylaApi.list_devices()`
#### Methods
* `find_device()`/`async_find_device()` Cause the device to emit an annoying chirp
* `get_file_property_url(property_name)`/`async_get_file_property_url(property_name)` Get the URL for the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_file_property(property_name)`/`async_get_file_property(property_name)` Get the contents of the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_metadata()`/`async_get_metadata()` Update some device metadata (`vac_model_number` and `vac_serial_number`)
* `set_operating_mode(mode)`/`async_set_operating_mode(mode)` Set the operating mode. This is just a thin wrapper
around `set_property_value`/`async_set_property_value` provided for convenience.
* mode: OperatingModes Mode to set, e.g., `OperatingModes.START` to start the vacuum
* `get_property_value(property_name)/async_get_property_value(property_name)`
Returns the value of `property_name`, cast to the appropriate type
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `set_property_value(property_name, property_value)/async_set_property_value(property_name, property_value)`
Set the value of `property_name`
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyName` value for the desired property
* `property_value: Any` New value. Type checking is currently left to the remote API.
* `update()`/`async_update(property_list=None)` Fetch the updated robot state from the remote api
* `property_list: Optional[Interable[str]]` An optional iterable of property names. If specified, only those
properties will be updated.
#### Properties
* `ayla_api` The underlying `AylaApi` object
* `error_code` Error code, if any. *NB: these can be very stale as they are not immediately reset in the API when the
error is cleared*.
* `error_text` English description of the `error_code`. The same caveat applies.
* `name` The device name as it appears in the SharkClean app
* `oem_model_number` A "rough" model number that does not distinguish, for example, between robots with and without
a self-emptying base
* `properties_full` A dictionary representing all known device properties and their metadata (type
`Dict[str, Dict]`)
* `property_values` A convenience accessor into `properties_full` mapping property names to values
* `serial_number` The unique device serial number used with the Ayla Networks API (NB: this name may change)
* `vac_model_number` The precise model number
* `vac_serial_number` The serial number printed on the device
### Enums
* `OperatingModes` Operation modes to control the vacuum (`START`, `STOP`, `PAUSE`, `RETURN`)
* `PowerModes` Vacuum power mode (`ECO`, `NORMAL`, `MAX`)
* `Properties` Properties to use with `get_property_value`/`set_property_value`
### TODOs:
* Add support for mapping and room selection
* Once we have mapping, it may be possible to use the RSSI property combined with an increased update frequency
to generate a wifi strength heatmap. Kind of orthogonal to the main purpose, but I really want to do this.
## License
[MIT](https://choosealicense.com/licenses/mit/)
%package -n python3-sharkiqpy
Summary: Python API for Shark IQ robots
Provides: python-sharkiqpy
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-sharkiqpy
# sharkiqpy
Unofficial SDK for Shark IQ robot vacuums, designed primarily to support an integration for [Home Assistant](https://www.home-assistant.io/).
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.
```bash
pip install sharkiqpy
```
## Usage
### Simple Operation
```python
from sharkiqpy import get_ayla_api, OperatingModes, Properties, PowerModes
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
ayla_api = get_ayla_api(USERNAME, PASSWORD)
ayla_api.sign_in()
shark_vacs = ayla_api.get_devices()
shark = shark_vacs[0]
shark.update()
shark.set_operating_mode(OperatingModes.START)
shark.return_to_base()
```
### Async operation
```python
import asyncio
from sharkiqpy import get_ayla_api, OperatingModes, SharkIqVacuum
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
async def main(ayla_api) -> SharkIqVacuum:
await ayla_api.async_sign_in()
shark_vacs = await ayla_api.async_get_devices()
shark = shark_vacs[0]
await shark.async_update()
await shark.async_find_device()
await shark.async_set_operating_mode(OperatingModes.START)
return shark
ayla_api = get_ayla_api(USERNAME, PASSWORD)
shark = asyncio.run(main(ayla_api))
```
## Documentation
### `get_ayla_api(username, password, websession=None)`
Returns and `AylaApi` object to interact with the Ayla Networks Device API conrolling the Shark IQ robot, with the `app_id` and `app_secret` parameters set for the Shark IQ robot.
### `class AylaAPI(username, password, app_id, app_secret, websession)`
Class for interacting with the Ayla Networks Device API underlying the Shark IQ controls.
* `username: str`
* `password: str`
* `app_id: str`
* `app_secret: str`
* `websession: Optional[aiohttp.ClientSession] = None` Optional `aiohttp.ClientSession` to use for async calls. If
one is not provided, a new `aiohttp.ClientSession` will be created at the first async call.
#### Methods
* `get_devices()`/`async_get_devices()` Get a list of `SharkIqVacuum`s for every device found in `list_devices()`
* `list_devices()`/`async_list_devices()` Get a list of known device description `dict`s
* `refesh_auth()`/`async_refesh_auth()` Refresh the authentication token
* `request(method, url, headers = None, auto_refresh = True, **kwargs)`/`async_request(...)` Submit an HTTP request to
the Ayla networks API with the auth header
* `method: str` An HTTP method, usually `'get'` or `'post'`
* `url: str`
* `headers: Optional[Dict] = None` Optional `dict` of HTTP headers besides the auth header, which is included
automatically
* `auto_refresh: bool = True` If `True`, automatically call `refesh_auth()`/`async_refesh_auth()` if the auth token
is near expiration
* `**kwargs` Passed on to `requests.request` or `aiohttp.ClientSession.request`
* `sign_in()`/`async_sign_in()` Authenticate
* `sign_out()`/`async_sign_out()` Sign out
### `class SharkIqRobot(ayla_api, device_dct)`
Primary API for interacting with Shark IQ vacuums
* `ayla_api: AylaApi` An `AylaApi` with an authenticated connection
* `device_dct: Dict` A `dict` describing the device, usually obtained from `AylaApi.list_devices()`
#### Methods
* `find_device()`/`async_find_device()` Cause the device to emit an annoying chirp
* `get_file_property_url(property_name)`/`async_get_file_property_url(property_name)` Get the URL for the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_file_property(property_name)`/`async_get_file_property(property_name)` Get the contents of the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_metadata()`/`async_get_metadata()` Update some device metadata (`vac_model_number` and `vac_serial_number`)
* `set_operating_mode(mode)`/`async_set_operating_mode(mode)` Set the operating mode. This is just a thin wrapper
around `set_property_value`/`async_set_property_value` provided for convenience.
* mode: OperatingModes Mode to set, e.g., `OperatingModes.START` to start the vacuum
* `get_property_value(property_name)/async_get_property_value(property_name)`
Returns the value of `property_name`, cast to the appropriate type
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `set_property_value(property_name, property_value)/async_set_property_value(property_name, property_value)`
Set the value of `property_name`
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyName` value for the desired property
* `property_value: Any` New value. Type checking is currently left to the remote API.
* `update()`/`async_update(property_list=None)` Fetch the updated robot state from the remote api
* `property_list: Optional[Interable[str]]` An optional iterable of property names. If specified, only those
properties will be updated.
#### Properties
* `ayla_api` The underlying `AylaApi` object
* `error_code` Error code, if any. *NB: these can be very stale as they are not immediately reset in the API when the
error is cleared*.
* `error_text` English description of the `error_code`. The same caveat applies.
* `name` The device name as it appears in the SharkClean app
* `oem_model_number` A "rough" model number that does not distinguish, for example, between robots with and without
a self-emptying base
* `properties_full` A dictionary representing all known device properties and their metadata (type
`Dict[str, Dict]`)
* `property_values` A convenience accessor into `properties_full` mapping property names to values
* `serial_number` The unique device serial number used with the Ayla Networks API (NB: this name may change)
* `vac_model_number` The precise model number
* `vac_serial_number` The serial number printed on the device
### Enums
* `OperatingModes` Operation modes to control the vacuum (`START`, `STOP`, `PAUSE`, `RETURN`)
* `PowerModes` Vacuum power mode (`ECO`, `NORMAL`, `MAX`)
* `Properties` Properties to use with `get_property_value`/`set_property_value`
### TODOs:
* Add support for mapping and room selection
* Once we have mapping, it may be possible to use the RSSI property combined with an increased update frequency
to generate a wifi strength heatmap. Kind of orthogonal to the main purpose, but I really want to do this.
## License
[MIT](https://choosealicense.com/licenses/mit/)
%package help
Summary: Development documents and examples for sharkiqpy
Provides: python3-sharkiqpy-doc
%description help
# sharkiqpy
Unofficial SDK for Shark IQ robot vacuums, designed primarily to support an integration for [Home Assistant](https://www.home-assistant.io/).
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.
```bash
pip install sharkiqpy
```
## Usage
### Simple Operation
```python
from sharkiqpy import get_ayla_api, OperatingModes, Properties, PowerModes
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
ayla_api = get_ayla_api(USERNAME, PASSWORD)
ayla_api.sign_in()
shark_vacs = ayla_api.get_devices()
shark = shark_vacs[0]
shark.update()
shark.set_operating_mode(OperatingModes.START)
shark.return_to_base()
```
### Async operation
```python
import asyncio
from sharkiqpy import get_ayla_api, OperatingModes, SharkIqVacuum
USERNAME = 'me@email.com'
PASSWORD = '$7r0nkP@s$w0rD'
async def main(ayla_api) -> SharkIqVacuum:
await ayla_api.async_sign_in()
shark_vacs = await ayla_api.async_get_devices()
shark = shark_vacs[0]
await shark.async_update()
await shark.async_find_device()
await shark.async_set_operating_mode(OperatingModes.START)
return shark
ayla_api = get_ayla_api(USERNAME, PASSWORD)
shark = asyncio.run(main(ayla_api))
```
## Documentation
### `get_ayla_api(username, password, websession=None)`
Returns and `AylaApi` object to interact with the Ayla Networks Device API conrolling the Shark IQ robot, with the `app_id` and `app_secret` parameters set for the Shark IQ robot.
### `class AylaAPI(username, password, app_id, app_secret, websession)`
Class for interacting with the Ayla Networks Device API underlying the Shark IQ controls.
* `username: str`
* `password: str`
* `app_id: str`
* `app_secret: str`
* `websession: Optional[aiohttp.ClientSession] = None` Optional `aiohttp.ClientSession` to use for async calls. If
one is not provided, a new `aiohttp.ClientSession` will be created at the first async call.
#### Methods
* `get_devices()`/`async_get_devices()` Get a list of `SharkIqVacuum`s for every device found in `list_devices()`
* `list_devices()`/`async_list_devices()` Get a list of known device description `dict`s
* `refesh_auth()`/`async_refesh_auth()` Refresh the authentication token
* `request(method, url, headers = None, auto_refresh = True, **kwargs)`/`async_request(...)` Submit an HTTP request to
the Ayla networks API with the auth header
* `method: str` An HTTP method, usually `'get'` or `'post'`
* `url: str`
* `headers: Optional[Dict] = None` Optional `dict` of HTTP headers besides the auth header, which is included
automatically
* `auto_refresh: bool = True` If `True`, automatically call `refesh_auth()`/`async_refesh_auth()` if the auth token
is near expiration
* `**kwargs` Passed on to `requests.request` or `aiohttp.ClientSession.request`
* `sign_in()`/`async_sign_in()` Authenticate
* `sign_out()`/`async_sign_out()` Sign out
### `class SharkIqRobot(ayla_api, device_dct)`
Primary API for interacting with Shark IQ vacuums
* `ayla_api: AylaApi` An `AylaApi` with an authenticated connection
* `device_dct: Dict` A `dict` describing the device, usually obtained from `AylaApi.list_devices()`
#### Methods
* `find_device()`/`async_find_device()` Cause the device to emit an annoying chirp
* `get_file_property_url(property_name)`/`async_get_file_property_url(property_name)` Get the URL for the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_file_property(property_name)`/`async_get_file_property(property_name)` Get the contents of the latest version of a `'file'`-type property
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `get_metadata()`/`async_get_metadata()` Update some device metadata (`vac_model_number` and `vac_serial_number`)
* `set_operating_mode(mode)`/`async_set_operating_mode(mode)` Set the operating mode. This is just a thin wrapper
around `set_property_value`/`async_set_property_value` provided for convenience.
* mode: OperatingModes Mode to set, e.g., `OperatingModes.START` to start the vacuum
* `get_property_value(property_name)/async_get_property_value(property_name)`
Returns the value of `property_name`, cast to the appropriate type
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyNames` value for the desired property
* `set_property_value(property_name, property_value)/async_set_property_value(property_name, property_value)`
Set the value of `property_name`
* `property_name: Union[str, PropertyName]` Either a `str` or `PropertyName` value for the desired property
* `property_value: Any` New value. Type checking is currently left to the remote API.
* `update()`/`async_update(property_list=None)` Fetch the updated robot state from the remote api
* `property_list: Optional[Interable[str]]` An optional iterable of property names. If specified, only those
properties will be updated.
#### Properties
* `ayla_api` The underlying `AylaApi` object
* `error_code` Error code, if any. *NB: these can be very stale as they are not immediately reset in the API when the
error is cleared*.
* `error_text` English description of the `error_code`. The same caveat applies.
* `name` The device name as it appears in the SharkClean app
* `oem_model_number` A "rough" model number that does not distinguish, for example, between robots with and without
a self-emptying base
* `properties_full` A dictionary representing all known device properties and their metadata (type
`Dict[str, Dict]`)
* `property_values` A convenience accessor into `properties_full` mapping property names to values
* `serial_number` The unique device serial number used with the Ayla Networks API (NB: this name may change)
* `vac_model_number` The precise model number
* `vac_serial_number` The serial number printed on the device
### Enums
* `OperatingModes` Operation modes to control the vacuum (`START`, `STOP`, `PAUSE`, `RETURN`)
* `PowerModes` Vacuum power mode (`ECO`, `NORMAL`, `MAX`)
* `Properties` Properties to use with `get_property_value`/`set_property_value`
### TODOs:
* Add support for mapping and room selection
* Once we have mapping, it may be possible to use the RSSI property combined with an increased update frequency
to generate a wifi strength heatmap. Kind of orthogonal to the main purpose, but I really want to do this.
## License
[MIT](https://choosealicense.com/licenses/mit/)
%prep
%autosetup -n sharkiqpy-0.1.9
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-sharkiqpy -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.9-1
- Package Spec generated
|