Commit Graph

450 Commits

Author SHA1 Message Date
Teemu R
047a84b60a
Release 0.6.0.dev0 (#609) 2024-01-04 00:28:29 +01:00
sdb9696
e9bf9f58ee
Allow serializing and passing of credentials_hashes in DeviceConfig (#607)
* Allow passing of credentials_hashes in DeviceConfig

* Update following review
2024-01-03 22:46:08 +01:00
Teemu R
3692e4812f
Implement wifi interface for tapodevice (#606)
* Implement wifi interface for tapodevice

* Implement wifi_join

Tested to work on P110

* Fix linting
2024-01-03 22:45:16 +01:00
gimpy88
c810298b04
Add support for KS205 and KS225 wall switches (#594)
* KS205 Fixture

* KS225 Fixture

* Added Smart.KasaSwitch device type

* Added KS225 to test

* Added variable color temp check

* Added supported devices to readme

* Removed parenthesis

* Updated fixtures

* Fixed for ruff
2024-01-03 19:31:42 +01:00
Teemu R
30c4e6a6a3
Cleanup credentials handling (#605)
* credentials: don't allow none to simplify checks

* Implement __bool__ for credentials

* Cleanup klaptransport cred usage

* Cleanup deviceconfig and tapodevice

* fix linting

* Pass dummy credentials for tests

* Remove __bool__ dunder and add docs to credentials

* Check for cred noneness in tapodevice.update()
2024-01-03 19:26:52 +01:00
Teemu R
10fc2c3c54
Pull up emeter handling to tapodevice base class (#601)
* Pull has_emeter property up to tapodevice base class

This will also use the existence of energy_monitoring in the component_nego query to decide if the device has the service.

* Move emeter related functions to tapodevice

* Remove supported_modules override for now

This should be done in a separate PR, if we want to expose the available components to cli and downstreams

* Dedent extra reqs

* Move extra_reqs initialization

* Fix tests
2024-01-03 19:04:34 +01:00
Teemu R
864ea92ece
Update P110(EU) fixture (#604) 2024-01-02 19:34:39 +01:00
Teemu R
9a2b513e6a
Update L530 aes fixture (#603) 2024-01-02 18:49:52 +01:00
sdb9696
ae5ad3e8c6
Add known smart requests to dump_devinfo (#597)
* Add known smart requests to dump_devinfo

* Move smartrequest.py to devtools

* Update post-review
2024-01-02 18:20:53 +01:00
Teemu R
5dafc1d1ed
Cleanup custom exception kwarg handling (#602)
* Cleanup custom exceptions

* Read custom keyword arguments from kwargs
* Pass all input args to the super

Earlier behavior:
Got error: AuthenticationException((('Error logging in: 192.168.xx.xx: LOGIN_ERROR(-1501)',), <SmartErrorCode.LOGIN_ERROR: -1501>))

New behavior:
Got error: AuthenticationException('Error logging in: 192.168.xx.xx: LOGIN_ERROR(-1501)')

* Pass UnsupportedDeviceException kwargs to parent, too
2024-01-02 16:24:09 +01:00
sdb9696
7646bc4542
Update P110(UK) fixture (#596) 2023-12-31 15:36:15 +01:00
sdb9696
fd9b3cd04c
Add L530(EU) klap fixture (#598) 2023-12-31 15:35:43 +01:00
sdb9696
1b7914277d
Fix dump_devinfo for unauthenticated (#593) 2023-12-29 20:42:02 +01:00
sdb9696
f6fd898faf
Add DeviceConfig to allow specifying configuration parameters (#569)
* Add DeviceConfig handling

* Update post review

* Further update post latest review

* Update following latest review

* Update docstrings and docs
2023-12-29 20:17:15 +01:00
alanblake
ec3ea39a37
Fix typo in cli.rst (#581) 2023-12-29 16:05:47 +01:00
Teemu R
1d5a9c35f4
Elevate --verbose to top-level option (#590)
* Elevate --verbose to be usable for all commands

* Fix tests
2023-12-29 16:04:41 +01:00
sdb9696
b66347116f
Add optional error code to exceptions (#585) 2023-12-20 20:16:23 +01:00
sdb9696
6819c746d7
Enable multiple requests in smartprotocol (#584)
* Enable multiple requests in smartprotocol

* Update following review

* Remove error_code parameter in exceptions
2023-12-20 18:08:04 +01:00
sdb9696
20ea6700a5
Do login entirely within AesTransport (#580)
* Do login entirely within AesTransport

* Remove login and handshake attributes from BaseTransport

* Add AesTransport tests

* Synchronise transport and protocol __init__ signatures and rename internal variables

* Update after review
2023-12-19 15:11:59 +01:00
sdb9696
209391c422
Improve CLI Discovery output (#583)
- Show discovery results for unsupported devices and devices that fail to authenticate.
- Rename `--show-unsupported` to `--verbose`.
- Remove separate `--timeout` parameter from cli discovery so it's not confused with `--timeout` now added to cli command.
- Add tests.
2023-12-19 13:50:33 +01:00
sdb9696
2e6c41d039
Improve smartprotocol error handling and retries (#578)
* Improve smartprotocol error handling and retries

* Update after review

* Enum to IntEnum and SLEEP_SECONDS_AFTER_TIMEOUT
2023-12-10 16:41:53 +01:00
Teemu R
a77af5fb3b
Request component_nego only once for tapodevice (#576)
Optimizes the update cycle a bit, as it's doubtful the components change over time
2023-12-10 00:32:30 +01:00
Teemu R
35a452168a
Log smartprotocol requests (#575)
* Log smartprotocol requests

Also, comment out encrypted secure_passthrough response for the time being

* Fix linting
2023-12-08 15:22:58 +01:00
Teemu R
1e2241ee95
Fix hsv setting for tapobulb (#573)
This fixes changing the color for L530:
* If color temp is set on the device, it overrides any hue/sat settings. We override it to zero which seems to work.
* L530 does not allow None/null for brightness, so we avoid passing it on to the device.
2023-12-08 15:16:45 +01:00
sdb9696
16ba87378d
Add EP25 smart fixture and improve test framework for SMART devices (#572) 2023-12-08 14:55:14 +01:00
sdb9696
b27a31a8a9
Add new methods to dump_devinfo and mask aliases (#574) 2023-12-08 14:29:07 +01:00
Steven Bytnar
be289a5751
Add KP125M fixture and allow passing credentials for tests (#567)
* Add KP125M fixture. Enable tapo auth in pytest.

* authentication is not just for tapo

* Use "##MASKEDNAME##" base64 for nickname and ssid.

---------

Co-authored-by: Teemu R. <tpr@iki.fi>
2023-12-08 00:04:50 +01:00
Teemu R
bd23d61687
Update readme with clearer instructions, tapo support (#571)
* Update readme with clearer instructions, tapo support

All in all, making the readme more approachable landing page:

* Link to provisioning docs from the beginning
* Hints about support for tapo devices
* Add some documentation about how to pass credentials
* Clearer usage instructions and links to find more information

* Lint
2023-12-06 22:54:14 +01:00
Teemu R
8cdd4f59f8
Use consistent naming for cli envvars (#570)
* Use consistent naming for cli envvars

* Fix linting
2023-12-05 23:20:29 +01:00
Teemu R
f9b5003da2
Add support for tapo bulbs (#558)
* Add support for tapo light bulbs

* Use TapoDevice for on/off

* Add tapobulbs to discovery

* Add partial support for effects

Activating the effect does not work as I thought it would,
but this implements rest of the interface from SmartLightStrip.

* Add missing __init__ for tapo package

* Make mypy happy

* Add docstrings to make ruff happy

* Implement state_information and has_emeter

* Import tapoplug from kasa.tapo package

* Add tapo L530 fixture

* Enable tests for L530 fixture

* Make ruff happy

* Update fixture filename

* Raise exceptions on invalid parameters

* Return results in a wrapped dict

* Implement set_*

* Reorganize bulbs to iot&smart, fix tests for smarts

* Fix linting

* Fix BULBS_LIGHT_STRIP back to LIGHT_STRIPS
2023-12-05 20:07:10 +01:00
Teemu R
5febd300ca
Add P110 fixture (#562)
* Add P110 fixture

* Move the fixture file to smart subdir

* Update fixture to have the region info

* Rename the fixture file to follow the convention
2023-12-05 16:58:25 +01:00
sdb9696
5e2fcd2cca
Re-add regional suffix to TAPO/SMART fixtures (#566) 2023-12-05 16:45:09 +01:00
sdb9696
01f3827d73
Fix transport retries after close (#568) 2023-12-05 15:56:29 +01:00
sdb9696
4a00199506
Add klap support for TAPO protocol by splitting out Transports and Protocols (#557)
* Add support for TAPO/SMART KLAP and seperate transports from protocols

* Add tests and some review changes

* Update following review

* Updates following review
2023-12-04 19:50:05 +01:00
Teemu R
347cbfe3bd
Make timeout configurable for cli (#564) 2023-12-04 16:44:27 +01:00
Steven Bytnar
bfd1d6ae0a
Kasa KP125M basic emeter support (#560)
* Add KP125M basic emeter support.

* Reduce diff.

* PR Comments
2023-12-03 15:41:46 +01:00
sdb9696
a6b7d73d79
Update dump_devinfo to produce new TAPO/SMART fixtures (#561) 2023-12-02 17:33:35 +01:00
sdb9696
63d64ad920
Add support for the protocol used by TAPO devices and some newer KASA devices. (#552)
* Add Tapo protocol support

* Update get_device_instance and test_unsupported following review
2023-11-30 13:10:49 +01:00
sdb9696
9de3f69033
Update dump_devinfo to include 20002 discovery results (#556)
* Fix dump_devinfo and add discovery_result to json

* Update following review.  Do not serialize aliases.

* Delete kasa/tests/fixtures/HS100(UK)_1.0_1.2.6.json
2023-11-29 20:01:20 +01:00
sdb9696
9728866afb
Re-add protocol_class parameter to connect (#551)
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-11-28 20:13:15 +01:00
J. Nick Koston
d3c2861e4a
Set TCP_NODELAY to avoid needless buffering (#554) 2023-11-27 09:25:49 -06:00
J. Nick Koston
e98252ff17
Move connect_single to SmartDevice.connect (#538)
This refactors `Discover.connect_single` by moving device instance construction into a separate device factory module.
New `SmartDevice.connect(host, *, port, timeout, credentials, device_type)` class method replaces the functionality of `connect_single`,
and also now allows constructing device instances without relying on UDP discovery for type discovery if `device_type` parameter is set.

---------

Co-authored-by: Teemu R. <tpr@iki.fi>
2023-11-21 23:48:53 +01:00
sdb9696
27c4799adc
Do not do update() in discover_single (#542) 2023-11-21 21:58:41 +01:00
sdb9696
30f217b8ab
Add klap protocol (#509)
* Add support for the new encryption protocol

This adds support for the new TP-Link discovery and encryption
protocols. It is currently incomplete - only devices without
username and password are current supported, and single device
discovery is not implemented.

Discovery should find both old and new devices. When accessing
a device by IP the --klap option can be specified on the command
line to active the new connection protocol.

sdb9696 - This commit also contains 16 later commits from Simon Wilkinson
squashed into the original

* Update klap changes 2023 to fix encryption, deal with kasa credential switching and work with new discovery changes

* Move from aiohttp to httpx

* Changes following review comments

---------

Co-authored-by: Simon Wilkinson <simon@sxw.org.uk>
2023-11-20 14:17:10 +01:00
Teemu R
bde07d117f
Add some more external links to README (#541)
This updates the README to include more resources for developers intersted as well as some tapo-related links.
2023-11-07 02:15:57 +01:00
sdb9696
26502982a0
Update discover single to handle hostnames (#539) 2023-11-07 02:15:41 +01:00
Teemu R
805e4b8588
Release 0.5.4 (#536)
The highlights of this maintenance release:

* Support to the alternative discovery protocol and foundational work to support other communication protocols, thanks to @sdb9696.
* Reliability improvements by avoiding overflowing device buffers, thanks to @cobryan05.
* Optimizations for downstream device accesses, thanks to @bdraco.
* Support for both pydantic v1 and v2.
2023-10-30 00:57:29 +01:00
Teemu R
87dcd42861
Add python3.12 and pypy-3.10 to CI (#532)
* Add python3.12 and pypy-3.10 to CI

Also, cleanup the action file a bit:
* Update action versions
* Remove commented out yaml
* Disable fail_ci_if_error for codecov

* Fix typo
2023-10-30 00:22:30 +01:00
Teemu R
c431dbb832
Use ruff and ruff format (#534)
Replaces the previously used linting and code formatting tools with ruff.
2023-10-29 23:15:42 +01:00
Teemu R
0061668c9f
Use trusted publisher for publishing to pypi (#531) 2023-10-29 16:30:37 +01:00