Commit Graph

734 Commits

Author SHA1 Message Date
Teemu R
55525fc58b
Unignore F401 for tests (#724)
* Unignore F401 for tests

* Fix linting
2024-01-30 00:15:58 +01:00
Teemu R
9e6896a08f
Various test code cleanups (#725)
* Separate fake protocols for iot and smart

* Move control_child impl into its own method

* Organize schemas into correct places

* Add test_childdevice

* Add missing return for _handle_control_child
2024-01-29 20:26:39 +01:00
Teemu R
1e26434205
Prepare 0.6.2 (#728)
[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.6.1...0.6.2)

Release highlights:
* Support for tapo power strips (P300)
* Performance improvements and bug fixes

**Implemented enhancements:**

- Implement alias set for tapodevice [\#721](https://github.com/python-kasa/python-kasa/pull/721) (@rytilahti)
- Initial support for tapos with child devices [\#720](https://github.com/python-kasa/python-kasa/pull/720) (@rytilahti)
- Avoid rebuilding urls for every request [\#715](https://github.com/python-kasa/python-kasa/pull/715) (@bdraco)
- Reduce the number of times creating the cipher in klap [\#712](https://github.com/python-kasa/python-kasa/pull/712) (@bdraco)
- Use hashlib for klap [\#711](https://github.com/python-kasa/python-kasa/pull/711) (@bdraco)
- Enable batching of multiple requests [\#662](https://github.com/python-kasa/python-kasa/pull/662) (@sdb9696)

**Merged pull requests:**

- Update L510E\(US\) fixture with mac prefix [\#722](https://github.com/python-kasa/python-kasa/pull/722) (@sdb9696)
- Add P300 fixture [\#717](https://github.com/python-kasa/python-kasa/pull/717) (@rytilahti)
- Use hashlib in place of hashes.Hash [\#714](https://github.com/python-kasa/python-kasa/pull/714) (@bdraco)
- Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport [\#710](https://github.com/python-kasa/python-kasa/pull/710) (@sdb9696)
- Add concrete XorTransport class with full implementation [\#646](https://github.com/python-kasa/python-kasa/pull/646) (@sdb9696)
2024-01-29 19:58:30 +01:00
Steven B
bc1503c40e
Fix TapoBulb state information for non-dimmable SMARTSWITCH (#726) 2024-01-29 19:52:22 +01:00
Teemu R
f8e273981c
Add P300 fixture (#717)
* Add P300 fixture

* fixture after update

* Add tests for p300
2024-01-29 18:14:30 +01:00
Teemu R
1ad2a05b65
Initial support for tapos with child devices (#720)
* Add ChildDevice and ChildProtocolWrapper

* Initialize & update children

* Fix circular imports

* Add dummy_protocol fixture and tests for unwrapping responseData

* Use dummy_protocol for existing smartprotocol tests

* Move _ChildProtocolWrapper to smartprotocol.py

* Use dummy_protocol for test multiple requests

* Use device_id instead of position for selecting the child

* Fix wrapping for regular requests

* Remove unused imports

* tweak

* rename child_device to childdevice

* Fix import
2024-01-29 17:11:29 +01:00
J. Nick Koston
b479b6d84d
Avoid rebuilding urls for every request (#715)
* Avoid rebuilding urls for every request

* more fixes

* more fixes

* make mypy happy

* reduce

* tweak

* fix tests

* fix tests

* tweak

* tweak

* lint

* fix type
2024-01-29 15:26:00 +00:00
Teemu R
69dcc0d8bb
Implement alias set for tapodevice (#721) 2024-01-29 11:57:32 +01:00
Steven B
9c0a831027
Enable batching of multiple requests (#662)
* Enable batching of multiple requests

* Test for debug enabled outside of loop

* tweaks

* tweaks

* tweaks

* Update kasa/smartprotocol.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* revert

* Update pyproject.toml

* Add batch test and make batch_size configurable

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Teemu R. <tpr@iki.fi>
2024-01-29 11:55:54 +01:00
Steven B
cedffc5c9f
Update L510E(US) fixture with mac prefix (#722) 2024-01-29 09:25:36 +00:00
J. Nick Koston
7e2be35e4b
Reduce the number of times creating the cipher in klap (#712) 2024-01-26 07:44:41 -10:00
J. Nick Koston
dd38225f51
Use hashlib in place of hashes.Hash (#714) 2024-01-26 06:57:56 -10:00
J. Nick Koston
fcd4883645
Use hashlib for klap since its faster (#711) 2024-01-26 09:33:18 +00:00
Steven B
0d0f56414c
Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport (#710)
* Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport

* Add test

* Update docs

* Fix ruff deleting deprecated import
2024-01-26 09:11:31 +00:00
Steven B
c318303255
Add concrete XorTransport class with full implementation (#646)
* Add concrete XorTransport class

* Update xortransport reset() docstring
2024-01-25 17:37:19 +00:00
Teemu R
c01c3c679c
Prepare 0.6.1 (#709)
[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.6.0.1...0.6.1)

Release highlights:
* Support for tapo wall switches
* Support for unprovisioned devices
* Performance and stability improvements

**Implemented enhancements:**

- Add support for tapo wall switches \(S500D\) [\#704](https://github.com/python-kasa/python-kasa/pull/704) (@bdraco)
- Add new cli command 'command' to execute arbitrary commands [\#692](https://github.com/python-kasa/python-kasa/pull/692) (@rytilahti)
- Allow raw-command and wifi without update [\#688](https://github.com/python-kasa/python-kasa/pull/688) (@rytilahti)
- Generate AES KeyPair lazily [\#687](https://github.com/python-kasa/python-kasa/pull/687) (@sdb9696)
- Add reboot and factory\_reset to tapodevice [\#686](https://github.com/python-kasa/python-kasa/pull/686) (@rytilahti)
- Try default tapo credentials for klap and aes [\#685](https://github.com/python-kasa/python-kasa/pull/685) (@sdb9696)
- Sleep between discovery packets [\#656](https://github.com/python-kasa/python-kasa/pull/656) (@sdb9696)

**Fixed bugs:**

- Do not crash on missing geolocation [\#701](https://github.com/python-kasa/python-kasa/pull/701) (@rytilahti)
- Fix P100 error getting conn closed when trying default login after login failure [\#690](https://github.com/python-kasa/python-kasa/pull/690) (@sdb9696)

**Documentation updates:**

- Add protocol and transport documentation [\#663](https://github.com/python-kasa/python-kasa/pull/663) (@sdb9696)
- Document authenticated provisioning [\#634](https://github.com/python-kasa/python-kasa/pull/634) (@rytilahti)

**Closed issues:**

- Consider handshake as still valid on ServerDisconnectedError [\#676](https://github.com/python-kasa/python-kasa/issues/676)
- AES Transport creates the key even if the device is offline [\#675](https://github.com/python-kasa/python-kasa/issues/675)
- how to provision new Tapo plug devices? [\#565](https://github.com/python-kasa/python-kasa/issues/565)
- Space out discovery requests [\#229](https://github.com/python-kasa/python-kasa/issues/229)

**Merged pull requests:**

- Add additional L900-10 fixture [\#707](https://github.com/python-kasa/python-kasa/pull/707) (@bdraco)
- Replace rich formatting stripper [\#706](https://github.com/python-kasa/python-kasa/pull/706) (@bdraco)
- Add support for the S500 [\#705](https://github.com/python-kasa/python-kasa/pull/705) (@bdraco)
- Fix overly greedy \_strip\_rich\_formatting [\#703](https://github.com/python-kasa/python-kasa/pull/703) (@bdraco)
- Ensure login token is only sent if aes state is ESTABLISHED [\#702](https://github.com/python-kasa/python-kasa/pull/702) (@bdraco)
- Update readme fixture checker and readme [\#699](https://github.com/python-kasa/python-kasa/pull/699) (@rytilahti)
- Fix test\_klapprotocol test duration [\#698](https://github.com/python-kasa/python-kasa/pull/698) (@sdb9696)
- Renew the handshake session 20 minutes before we think it will expire [\#697](https://github.com/python-kasa/python-kasa/pull/697) (@bdraco)
- Add --batch-size hint to timeout errors in dump\_devinfo [\#696](https://github.com/python-kasa/python-kasa/pull/696) (@sdb9696)
- Add L930-5 fixture [\#694](https://github.com/python-kasa/python-kasa/pull/694) (@bdraco)
- Add fixtures for L510E [\#693](https://github.com/python-kasa/python-kasa/pull/693) (@bdraco)
- Refactor aestransport to use a state enum [\#691](https://github.com/python-kasa/python-kasa/pull/691) (@bdraco)
- Update transport close/reset behaviour [\#689](https://github.com/python-kasa/python-kasa/pull/689) (@sdb9696)
- Check README for supported models [\#684](https://github.com/python-kasa/python-kasa/pull/684) (@rytilahti)
- Add P100 test fixture [\#683](https://github.com/python-kasa/python-kasa/pull/683) (@bdraco)
- Make dump\_devinfo request batch size configurable [\#681](https://github.com/python-kasa/python-kasa/pull/681) (@sdb9696)
- Add updated L920 fixture [\#680](https://github.com/python-kasa/python-kasa/pull/680) (@bdraco)
- Update fixtures from test devices [\#679](https://github.com/python-kasa/python-kasa/pull/679) (@bdraco)
- Show discovery data for state with verbose [\#678](https://github.com/python-kasa/python-kasa/pull/678) (@rytilahti)
- Add L530E\(US\) fixture [\#674](https://github.com/python-kasa/python-kasa/pull/674) (@bdraco)
- Add P135 fixture [\#673](https://github.com/python-kasa/python-kasa/pull/673) (@bdraco)
- Rename base TPLinkProtocol to BaseProtocol [\#669](https://github.com/python-kasa/python-kasa/pull/669) (@sdb9696)
- Add 1003 \(TRANSPORT\_UNKNOWN\_CREDENTIALS\_ERROR\) [\#667](https://github.com/python-kasa/python-kasa/pull/667) (@rytilahti)
2024-01-25 09:32:45 +01:00
J. Nick Koston
716b1f82d9
Add support for the S500 (#705)
* Add support for the S500D

* tweak

* Add S505
2024-01-25 09:07:01 +01:00
J. Nick Koston
cba073ebde
Add support for tapo wall switches (S500D) (#704)
* Add support for the S500D

* tweak

* Update README.md
2024-01-25 08:54:56 +01:00
J. Nick Koston
fa94548723
Add additional L900-10 fixture (#707) 2024-01-25 08:53:43 +01:00
J. Nick Koston
fa6bc59b29
Replace rich formatting stripper (#706)
* Revert "Fix overly greedy _strip_rich_formatting (#703)"

This reverts commit ae6a31463e.

* Improve rich formatter stripper

reverts and replaces #703
2024-01-25 08:49:26 +01:00
J. Nick Koston
8947ffbc94
Add L930-5 fixture (#694)
* Add L930-5 fixture

* Mark L930-5 as variable temp

* Update readme

* Fix overly greedy _strip_rich_formatting

---------

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2024-01-24 22:31:01 +00:00
J. Nick Koston
3235ba620d
Add updated L920 fixture (#680)
* Add updated L920 fixture

* Fix overly greedy _strip_rich_formatting

---------

Co-authored-by: Teemu R <tpr@iki.fi>
2024-01-24 22:29:55 +00:00
Teemu R
2d8b966e5b
Document authenticated provisioning (#634) 2024-01-24 22:09:27 +00:00
J. Nick Koston
ae6a31463e
Fix overly greedy _strip_rich_formatting (#703) 2024-01-24 11:53:28 -10:00
J. Nick Koston
3df837cc82
Ensure login token is only sent if aes state is ESTABLISHED (#702) 2024-01-24 09:43:42 -10:00
Teemu R
aecf0ecd8a
Do not crash on missing geolocation (#701)
If 'has_set_location_info' is false, the geolocation is missing.
2024-01-24 12:21:37 +00:00
Steven B
f7c04bcef8
Add --batch-size hint to timeout errors in dump_devinfo (#696)
* Add --batch-size hint to timeout errors in dump_devinfo

* Add _echo_error function for displaying critical errors
2024-01-24 10:40:36 +01:00
J. Nick Koston
bab40d43e6
Renew the handshake session 20 minutes before we think it will expire (#697)
* Renew the KLAP handshake session 20 minutes before we think it will expire

Currently we assumed the clocks were perfectly aligned and the handshake
session lasted 20 hours.  We now add a 20 minute buffer

* use timeout cookie when available
2024-01-24 10:11:27 +01:00
J. Nick Koston
24c645746e
Refactor aestransport to use a state enum (#691) 2024-01-23 22:50:25 -10:00
Teemu R
3f40410db3
Update readme fixture checker and readme (#699) 2024-01-24 09:36:45 +01:00
Steven B
eb217a748c
Fix test_klapprotocol test duration (#698) 2024-01-23 22:20:44 -10:00
Teemu R
8b566757c3
Add new cli command 'command' to execute arbitrary commands (#692)
* Add new cli command 'command' to execute arbitrary commands

This deprecates 'raw-command', which requires positional argument for module,
in favor of new 'command' that accepts '--module' option for IOT devices.

* Pull block list to the module level
2024-01-24 09:10:55 +01:00
J. Nick Koston
5907dc763a
Add fixtures for L510E (#693)
* Add fixtures for L510E

* mac
2024-01-24 06:59:39 +00:00
Teemu R
52c3fb4d52
Add 1003 (TRANSPORT_UNKNOWN_CREDENTIALS_ERROR) (#667) 2024-01-24 00:12:01 +01:00
Steven B
1788c50146
Update transport close/reset behaviour (#689)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-01-23 12:15:18 -10:00
Teemu R
e576fcdb46
Allow raw-command and wifi without update (#688)
* Allow raw-command and wifi without update

* Call update always but on wifi&raw-command

* Add tests

* Skip update also if device_family was defined, as device factory performs an update
2024-01-23 22:58:57 +01:00
Steven B
f045696ebe
Fix P100 error getting conn closed when trying default login after login failure (#690) 2024-01-23 11:51:07 -10:00
Steven B
e233e377ad
Generate AES KeyPair lazily (#687)
* Generate AES KeyPair lazily

* Fix coverage

* Update post-review

* Fix pragma

* Make json dumps consistent between python and orjson

* Add comment

* Add comments re json parameter in HttpClient
2024-01-23 15:29:27 +00:00
Steven B
718983c401
Try default tapo credentials for klap and aes (#685)
* Try default tapo credentials for klap and aes

* Add tests
2024-01-23 14:44:32 +00:00
Teemu R
c8ac3a29c7
Add reboot and factory_reset to tapodevice (#686)
* Add reboot and factory_reset to tapodevice

* Add test for reboot command

* Fix mocking as different protocols use different methods for comms..
2024-01-23 14:26:47 +01:00
Teemu R
cfbdf7c64a
Show discovery data for state with verbose (#678)
* Show discovery data for state with verbose

* Remove duplicate discovery printout on discovery, add a newline for readability
2024-01-23 13:24:17 +01:00
Steven B
1db955b05e
Make request batch size configurable and avoid multiRequest if 1 (#681) 2024-01-23 11:33:07 +01:00
Teemu R
c1f2f8fe67
Check README for supported models (#684)
* Check README for supported models

* Use poetry for running due to imports

* Update README
2024-01-23 10:14:59 +00:00
J. Nick Koston
d5fdf05ed2
Add P100 test fixture (#683) 2024-01-23 10:12:24 +00:00
J. Nick Koston
abd3ee0768
Add P135 fixture (#673)
* Add P135 fixture

This device is a dimmer but we currently treat it as a on/off

* add to conftest
2024-01-23 08:31:19 +01:00
J. Nick Koston
65c47a9373
Update fixtures from test devices (#679)
* Update fixtures from test devices

* move l920 to another pr
2024-01-23 08:12:54 +01:00
J. Nick Koston
37f522c763
Add L530E(US) fixture (#674) 2024-01-23 06:24:08 +01:00
Steven B
ee487ad837
Sleep between discovery packets (#656)
* Sleep between discovery packets

* Add tests
2024-01-22 18:25:23 +01:00
Steven B
6b0a72d5a7
Add protocol and transport documentation (#663)
* Add protocol and transport documentation

* Update post review
2024-01-22 17:45:19 +01:00
Steven B
14acc8550e
Rename base TPLinkProtocol to BaseProtocol (#669) 2024-01-22 16:28:30 +01:00