Commit Graph

216 Commits

Author SHA1 Message Date
Steven B
3e0cd07b7c
Update docs for newer devices and DeviceConfig (#614)
* Update docs for newer devices and DeviceConfig

* Tweak docs post review

* Move sentence to newline

* Update post review

* Update following review
2024-01-10 20:13:14 +01:00
Steven B
897db674c2
Add L900-10 fixture and it's additional component requests (#629) 2024-01-10 19:40:36 +01:00
J. Nick Koston
460054ced7
Avoid recreating struct each request in legacy protocol (#628) 2024-01-09 13:51:04 -10:00
Nathan Wreggit
cfe694e5de
Get child emeters with CLI (#623)
* Get child emeters with CLI

* Avoid extra IO when not que querying the child emeter
2024-01-05 02:25:24 +01:00
Teemu R
2d8a8d9511
Add update-credentials command (#620)
* Add change credentials command

* Rename command and add prompts for credential update
2024-01-05 02:25:15 +01:00
J. Nick Koston
554fe0a96e
Avoid linear search for emeter realtime and emeter_today (#622)
* Avoid linear search for emeter realtime and emeter_today

Most of the time the data we want is at the end of the
list so we now search backwards to avoid having to
scale all the data and throw most of it away

* more tweaks

* coverage

* coverage

* preen

* coverage

* branch cover
2024-01-05 02:01:00 +01:00
J. Nick Koston
efd67b9261
Add P125M and update EP25 fixtures (#621)
* Add P125M and update EP25 fixtures

* fix: adjust tests
2024-01-05 00:01:34 +01:00
Teemu R
17d96064c2
Mark L900-5 as supported (#617)
* Add fixture for L900-5

* Update readme
2024-01-04 19:52:11 +01:00
Teemu R
7a3eedeee9
Check the ct range for color temp support (#619) 2024-01-04 19:28:48 +01:00
sdb9696
b156defc3c
Fix cli discover bug with None username/password (#615) 2024-01-04 19:17:48 +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
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
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
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