Commit Graph

69 Commits

Author SHA1 Message Date
Steven B.
32671da9e9
Move tests folder to top level of project (#1242) 2024-11-11 10:11:31 +00:00
Teemu R.
4640dfaedc
parse_pcap_klap: various code cleanups (#1138)
Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
2024-11-04 10:24:58 +00:00
Steven B.
54f0e91c04
Add component queries to smartcamera devices (#1223) 2024-11-01 14:52:39 +00:00
Steven B.
1f1d50dd5c
Fix mypy errors in parse_pcap_klap (#1214) 2024-10-29 17:57:40 +00:00
Steven B.
7483411ca2
Add trigger_logs and double_click to dump_devinfo helper (#1208) 2024-10-29 09:50:27 +00:00
Steven B.
4aec9d302f
Allow enabling experimental devices from environment variable (#1194) 2024-10-29 09:30:30 +00:00
Teemu R.
d30d116f37
dump_devinfo: query get_current_brt for iot dimmers (#1209) 2024-10-29 10:30:13 +01:00
Teemu R.
0287606235
Add TC65 fixture (#1200) 2024-10-28 13:47:24 +01:00
Steven B.
8ee8c17bdc
Update smartcamera to support single get/set/do requests (#1187)
Not supported by H200 hub
2024-10-24 13:11:28 +01:00
Steven B.
acd0202cab
Update dump_devinfo for smart camera protocol (#1169)
Introduces the child camera protocol wrapper, required to get the child device info with the new protocol.
2024-10-18 12:06:22 +01:00
Steven B.
81e2685605
Send empty dictionary instead of null for iot queries (#1145) 2024-10-01 12:47:36 +01:00
Teemu R.
db80c383a9
parse_pcap_klap: require source host (#1137)
Adds a mandatory `--source-host` to make sure the correct handshake
is captured when multiple hosts are communicating with the target device.
2024-09-30 09:15:16 +01:00
Teemu R.
130e1b6023
parse_pcap_klap: use request_uri for matching the response (#1136)
tshark 4.4.0 does not have response_for_uri, this fixes response
detection by using request_uri, too.
2024-09-28 20:20:47 +02:00
Steven B.
a967d5cd3a
Migrate from poetry to uv for dependency and package management (#986) 2024-09-06 15:48:43 +01:00
Steven B.
91bf9bb73d
Fix generate_supported pre commit to run in venv (#1085)
I noticed after building a new linux instance that running `git commit`
when the virtual environment is not active causes the pre-commit to
fail, as the `generate_supported` hook is not explicitly configured to
run in the virtual env. This PR calls `generate_supported` via the
`run-in-env.sh` script.
2024-07-28 20:41:33 +02:00
Steven B.
7416e855f1
Fix mypy pre-commit hook on windows (#1081) 2024-07-25 09:11:48 +01:00
Steven B.
c19389f236
Fix parse_pcap_klap on windows and support default credentials (#1068)
- Fixes issue running pyshark on new thread in windows
- Fixes bug if handshake repeated during capture
- Tries the default tplink hardcoded credentials as per the library
2024-07-17 08:34:12 +01:00
Carter Strickland
7e9b1687d0
Decrypt KLAP data from PCAP files (#1041)
Allows for decryption of pcap files capturing klap communication with devices.
2024-07-15 13:18:43 +01:00
Steven B
983aacbc24
Structure cli into a package (#1038)
PR with just the initial structural changes for the cli to be a package.
Subsequent PR will break out `main.py` into modules. Doing it in two
stages ensure that the commit history will be continuous for `cli.py` >
`cli/main.py`
2024-07-04 14:52:01 +02:00
Steven B
905a14895d
Handle module errors more robustly and add query params to light preset and transition (#1036)
Ensures that all modules try to access their data in `_post_update_hook` in a safe manner and disable themselves if there's an error.
Also adds parameters to get_preset_rules and get_on_off_gradually_info to fix issues with recent firmware updates.
[#1033](https://github.com/python-kasa/python-kasa/issues/1033)
2024-07-04 08:02:50 +01:00
Steven B
416d3118bf
Configure mypy to run in virtual environment and fix resulting issues (#989)
For some time I've noticed that my IDE is reporting mypy errors that the
pre-commit hook is not picking up. This is because [mypy
mirror](https://github.com/pre-commit/mirrors-mypy) runs in an isolated
pre-commit environment which does not have dependencies installed and it
enables `--ignore-missing-imports` to avoid errors.

This is [advised against by
mypy](https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker)
for obvious reasons:

> We recommend avoiding --ignore-missing-imports if possible: it’s
equivalent to adding a # type: ignore to all unresolved imports in your
codebase.

This PR configures the mypy pre-commit hook to run in the virtual
environment and addresses the additional errors identified as a result.
It also introduces a minimal mypy config into the `pyproject.toml`

[mypy errors identified without the fixes in this
PR](https://github.com/user-attachments/files/15896693/mypyerrors.txt)
2024-06-19 15:07:59 +02:00
Steven B
be5202ccb7
Make device initialisation easier by reducing required imports (#936)
Adds username and password arguments to discovery to remove the need to import Credentials.
Creates TypeAliases in Device for connection configuration classes and DeviceType.
Using the API with these changes will only require importing either Discover or Device
depending on whether using Discover.discover() or Device.connect() to 
initialize and interact with the API.
2024-06-03 19:06:54 +01:00
Teemu R
30e37038d7
Fix passing custom port for dump_devinfo (#938) 2024-06-03 16:46:38 +01:00
Steven B
9473d97ad2
Create common interfaces for remaining device types (#895)
Introduce common module interfaces across smart and iot devices and provide better typing implementation for getting modules to support this.
2024-05-10 19:29:28 +01:00
Steven B
f063c83378
Add child devices from hubs to generated list of supported devices (#898)
Updates generate_supported hook to include child devices of hubs in the list of supported devices.
2024-05-07 07:48:47 +01:00
Teemu R
88381f270f
Use Path.save for saving the fixtures (#894)
This might fix saving of fixture files on Windows, but it's a good
practice to use pathlib where possible.
2024-05-03 13:57:43 +02:00
Steven B
6724506fab
Update dump_devinfo to print original exception stack on errors. (#882) 2024-04-29 14:33:46 +01:00
Steven B
03a0ef3cc3
Include component_nego with child fixtures (#858) 2024-04-22 19:17:11 +02:00
Steven B
203bd79253
Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
Steven B
da441bc697
Update poetry locks and pre-commit hooks (#837)
Also updates CI pypy versions to be 3.9 and 3.10 which are the currently
[supported
versions](https://www.pypy.org/posts/2024/01/pypy-v7315-release.html).
Otherwise latest cryptography doesn't ship with pypy3.8 wheels and is
unable to build on windows.

Also updates the `codecov-action` to v4 which fixed some intermittent
uploading errors.
2024-04-16 20:21:20 +02:00
Steven B
ced879498b
Put child fixtures in subfolder (#809)
This should prevent child fixtures from hubs breaking tests due to
missing discovery info. To get these devices in `filter_fixtures`
include protocol string of `SMART.CHILD`.
2024-03-06 15:54:55 +01:00
Steven B
fcad0d2344
Add WallSwitch device type and autogenerate supported devices docs (#758) 2024-03-01 18:32:45 +00:00
Steven B
24344b71f5
Update dump_devinfo to collect child device info (#796)
Will create separate fixture files if the model of the child devices
differs from the parent (i.e. hubs). Otherwise the child device info
will be under `child_devices`
2024-02-28 17:04:57 +01:00
Teemu R
a73e2a9ede
Add H100 fixtures (#737)
One direct out of the box, another with upgraded fw & t315
2024-02-24 00:12:19 +01:00
Benjamin Ness
f965b14021
Add feature for ambient light sensor (#787) 2024-02-22 19:11:30 +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
Teemu R
e86dcb6bf5
Fix dump_devinfo scrubbing for ks240 (#765) 2024-02-19 00:08:39 +01:00
Steven B
57835276e3
Fix devtools for P100 and add fixture (#753) 2024-02-14 19:43:10 +00:00
Steven B
0d119e63d0
Refactor devices into subpackages and deprecate old names (#716)
* Refactor devices into subpackages and deprecate old names

* Tweak and add tests

* Fix linting

* Remove duplicate implementations affecting project coverage

* Update post review

* Add device base class attributes and rename subclasses

* Rename Module to BaseModule

* Remove has_emeter_history

* Fix missing _time in init

* Update post review

* Fix test_readmeexamples

* Fix erroneously duped files

* Clean up iot and smart imports

* Update post latest review

* Tweak Device docstring
2024-02-04 16:20:08 +01:00
Teemu R
1acf4e86da
Retain last two chars for children device_id (#733) 2024-02-01 19:27:01 +01: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
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
Teemu R
3f40410db3
Update readme fixture checker and readme (#699) 2024-01-24 09:36:45 +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
Teemu R
f77e87dc5d
dump_devinfo improvements (#657)
* dump_devinfo improvements

* Scrub only the last three bytes for mac addresses
* Add --target to allow creating fixtures based on discovery
* Save fixtures directly to correct location, add --basedir to allow defining the location of repository root
* Add --autosave to disable prompting for saving

* Update fixtures for devices I have

* Add fixture for HS110 hw 4.0 fw 1.0.4

* Improve help strings

* Fix tests

* Update devtools README

* Default to discovery if no host/target given
2024-01-20 14:20:08 +01: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
Steven B
897db674c2
Add L900-10 fixture and it's additional component requests (#629) 2024-01-10 19:40:36 +01:00
Teemu R
7e6eaf4ab2
Use consistent envvars for dump_devinfo credentials (#618) 2024-01-04 19:28:59 +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