Teemu R.
3e43781bb2
Add flake8-logging (LOG) and flake8-logging-format (G) for ruff ( #1104 )
...
Enables rules LOG (flake8-logging) and G (flake8-logging-format) for
ruff. This will catch eager log message formatting, among other similar
issues.
2024-08-30 16:13:14 +02:00
Steven B.
06ff598d9c
Raise KasaException on decryption errors ( #1078 )
...
Currently if the library encounters an invalid decryption error it
raises a value error. This PR wraps it in a KasaException so consumers
such as HA can catch an expected library exception.
2024-07-22 20:33:31 +02:00
Steven B.
c4f015a2fb
Redact sensitive info from debug logs ( #1069 )
...
Redacts sensitive data when debug logging device responses such as mac,
location and usernames
2024-07-17 19:57:09 +02:00
Steven B.
b220beb811
Use monotonic time for query timing ( #1070 )
...
To fix intermittent issues with [windows
CI](https://github.com/python-kasa/python-kasa/actions/runs/9952477932/job/27493918272?pr=1068 ).
Probably better to use monotonic here anyway.
```
FAILED kasa/tests/test_smartdevice.py::test_update_module_update_delays[L530E(EU)_3.0_1.1.6.json-SMART] - ValueError: Clock moved backwards. Refusing to generate ID.
```
2024-07-16 14:25:32 +02:00
Steven B
b8a87f1c57
Fix credential hash to return None on empty credentials ( #1029 )
...
If discovery is triggered without credentials and discovers devices requiring authentication,
blank credentials are used to initialise the protocols and no connection is actually made.
In this instance we should not return the credentials_hash for blank credentials as it will be invalid.
2024-07-02 13:43:37 +01:00
Steven B
203bd79253
Enable and convert to future annotations ( #838 )
2024-04-17 15:39:24 +02:00
Steven B
a87fc3b766
Retry query on 403 after succesful handshake ( #785 )
...
If a handshake session becomes invalid the device returns 403 on send and an `AuthenticationError` is raised which prevents a retry, however a retry would be successful. In HA this causes devices to go into reauth flow which is not necessary.
2024-02-22 18:02:03 +01:00
Steven B
8c39e81a40
Rename and deprecate exception classes ( #739 )
...
# Public #
SmartDeviceException -> KasaException
UnsupportedDeviceException(SmartDeviceException) -> UnsupportedDeviceError(KasaException)
TimeoutException(SmartDeviceException, asyncio.TimeoutError) -> TimeoutError(KasaException, asyncio.TimeoutError)
Add new exception for error codes -> DeviceError(KasaException)
AuthenticationException(SmartDeviceException) -> AuthenticationError(DeviceError)
# Internal #
RetryableException(SmartDeviceException) -> _RetryableError(DeviceError)
ConnectionException(SmartDeviceException) -> _ConnectionError(KasaException)
2024-02-21 16:52:55 +01:00
Steven B
6ab17d823c
Reduce AuthenticationExceptions raising from transports ( #740 )
...
* Reduce AuthenticationExceptions raising from transports
* Make auth failed test ids easier to read
* Test invalid klap response length
2024-02-05 21:49:26 +01:00
Teemu R
fae071f0df
Fix port-override for aes&klap transports ( #734 )
...
* Fix port-override for aes&klap transports
* Add tests for port override
2024-02-03 15:28:20 +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
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
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
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
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
J. Nick Koston
8523800b23
Fix minor typos in docstrings ( #659 )
2024-01-20 02:40:21 +01:00
J. Nick Koston
d62b5a55cc
Improve and document close behavior ( #654 )
...
* Close connection on smartprotocol timeout
* tweaks
2024-01-19 21:30:01 +01:00
Steven B
bedf05ce3b
Remove time logging in debug message ( #645 )
2024-01-18 08:32:58 -10:00
Steven B
3b1b0a3c21
Encapsulate http client dependency ( #642 )
...
* Encapsulate http client dependency
* Store cookie dict as variable
* Update post-review
2024-01-18 10:57:33 +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
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
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
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
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
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