You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Multiple models outlet support and logging logic (#425)
- Fix Core purifiers data model bug
- Fix ESW03-USA and ESW01-USA device support
- Documentation and Usage Improvements
- Added contributing documentation with details on device captures
- Clean up logging logic for the library to not change the loggers.
Debug logging must now be enabled outside of the library.
- Fix smart tower fan levels
- Removed duplicate mode for 6000s
- Fix support for WHOPLUG and BSDOG01/02 outlets
If you want to reuse your token and account_id between runs. The `VeSync.auth` object holds the credentials and helper methods to save and load credentials.
302
+
If you want to reuse your token and account_id between runs. The `VeSync.auth` object holds the credentials and helper methods to save and load credentials. See the [Authentication Documentation](https://webdjoe.github.io/pyvesync/latest/authentication.md) for more details.
Devices are stored in the respective lists in the instantiated `VeSync` class:
355
+
Devices are stored in the `VeSync.devices` attribute, which is a `DeviceContainer` instance that acts as a mutable set. The `DeviceContainer` has properties for each product type that return lists of device instances:
361
356
362
357
```python
363
358
await manager.login() # Asynchronous
@@ -394,15 +389,22 @@ See the [device documentation](https://webdjoe.github.io/pyvesync/latest/devices
394
389
395
390
## Debug mode and redact
396
391
397
-
To make it easier to debug, there is a `debug` argument in the `VeSync`method. This prints out your device list and any other debug log messages.
392
+
To set debug, use the `logger` object in the `VeSync`class. Setting the logger level to `DEBUG` will print debug information to the console. The `log_to_file()` method can be used to log to a file.
398
393
399
394
The `redact` argument removes any tokens and account identifiers from the output to allow for easier sharing. The `redact` argument has no impact if `debug` is not `True`.
400
395
396
+
This is an example of debug mode with redact enabled:
397
+
401
398
```python
399
+
import logging
402
400
import asyncio
403
401
import aiohttp
404
402
from pyvesync.vesync import VeSync
405
403
404
+
logger = logging.getLogger("pyvesync")
405
+
logger.setLevel(logging.DEBUG)
406
+
407
+
406
408
asyncdefmain():
407
409
asyncwith VeSync("user", "password") as manager:
408
410
manager.debug =True
@@ -420,6 +422,31 @@ if __name__ == "__main__":
420
422
asyncio.run(main())
421
423
```
422
424
425
+
### Logging to File
426
+
427
+
To log to a file, use the `log_to_file()` method of the `VeSync` class. Pass the file path as an argument.
428
+
429
+
```python
430
+
431
+
import asyncio
432
+
from pyvesync import VeSync
433
+
434
+
asyncdefmain():
435
+
asyncwith VeSync("user", "password") as manager:
436
+
manager.log_to_file("pyvesync.log", level=logging.DEBUG, stdout=True) # stdout argument prints log to console as well
437
+
await manager.login()
438
+
await manager.update()
439
+
440
+
outlet = manager.outlets[0]
441
+
await outlet.update()
442
+
await outlet.turn_off()
443
+
outlet.display()
444
+
445
+
if__name__=="__main__":
446
+
asyncio.run(main())
447
+
448
+
```
449
+
423
450
## Feature Requests
424
451
425
452
Before filing an issue to request a new feature or device, please ensure that you will take the time to test the feature throuroughly. New features cannot be simply tested on Home Assistant. A separate integration must be created which is not part of this library. In order to test a new feature, clone the branch and install into a new virtual environment.
Test functionality with a script, please adjust methods and logging statements to the device you are testing.
448
475
449
-
`test.py`
476
+
See `[testing_scripts](./testing_scripts/README.md)` for a fully functioning test script for all devices.
450
477
451
478
```python
452
479
import asyncio
@@ -456,7 +483,10 @@ import json
456
483
from functool import chain
457
484
from pyvesync import VeSync
458
485
459
-
logger = logging.getLogger(__name__)
486
+
vs_logger = logging.getLogger("pyvesync")
487
+
vs_logger.setLevel(logging.DEBUG)
488
+
489
+
logger = logging.getLogger('pyvesync_test')
460
490
logger.setLevel(logging.DEBUG)
461
491
462
492
USERNAME="YOUR USERNAME"
@@ -466,7 +496,7 @@ DEVICE_NAME = "Device" # Device to test
466
496
467
497
asyncdeftest_device():
468
498
# Instantiate VeSync class and login
469
-
asyncwith VeSync(USERNAME, PASSWORD, debug=True, redact=True) as manager:
499
+
asyncwith VeSync(USERNAME, PASSWORD, redact=True) as manager:
470
500
await manager.login()
471
501
472
502
# Pull and update devices
@@ -525,35 +555,11 @@ if __name__ == "__main__":
525
555
526
556
## Device Requests
527
557
528
-
SSL pinning makes capturing packets much harder. In order to be able to capture packets, SSL pinning needs to be disabled before running an SSL proxy. Use an Android emulator such as Android Studio, which is available for Windows and Linux for free. Download the APK from APKPure or a similiar site and use [Objection](https://github.com/sensepost/objection) or [Frida](https://frida.re/docs/gadget/). Followed by capturing the packets with Charles Proxy or another SSL proxy application.
529
-
530
-
Be sure to capture all packets from the device list and each of the possible device menus and actions. Please redact the `accountid` and `token` from the captured packets. If you feel you must redact other keys, please do not delete them entirely. Replace letters with "A" and numbers with "1", leave all punctuation intact and maintain length.
531
-
532
-
For example:
533
-
534
-
Before:
535
-
536
-
```json
537
-
{
538
-
"tk": "abc123abc123==3rf",
539
-
"accountId": "123456789",
540
-
"cid": "abcdef12-3gh-ij"
541
-
}
542
-
```
543
-
544
-
After:
545
-
546
-
```json
547
-
{
548
-
"tk": "AAA111AAA111==1AA",
549
-
"accountId": "111111111",
550
-
"cid": "AAAAAA11-1AA-AA"
551
-
}
552
-
```
558
+
If you would like to request a new device to be added to the library, please open an issue on GitHub. Be sure to include the device model number and a link to the product page. If you are able to provide packet captures or are willing to share the device temporarily, please indicate that in the issue. See the [Packet Capturing for New Device Support](https://webdjoe.github.io/pyvesync/latest/development/capturing.md) document for more details.
553
559
554
560
## Contributing
555
561
556
-
All [contributions](CONTRIBUTING.md) are welcome.
562
+
All [contributions](https://webdjoe.github.io/pyvesync/latest/development/CONTRIBUTING.md) are welcome.
Copy file name to clipboardExpand all lines: docs/development/capturing.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,6 @@ day trial is sufficient for this purpose. If you do like the software, support t
19
19
20
20
5.**frida-server**: Download the latest frida-server from [frida-server](https://github.com/frida/frida/releases). Choose the release that matches the architecture of the MuMu emulator - `frida-server-x.x.x-android-x86_x64.xz`. Extract the `frida-server` binary and place it in the project directory.
0 commit comments