Commit Graph

93 Commits

Author SHA1 Message Date
Steven B.
5918e4daa7
Enable saving of fixture files without git clone (#1375)
Some checks are pending
CI / Perform linting checks (3.13) (push) Waiting to run
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Blocked by required conditions
CodeQL checks / Analyze (python) (push) Waiting to run
Allows `dump_devinfo` to be run without fixture subfolders present from cloned repository
2024-12-16 13:42:42 +00:00
Steven B.
d03a387a74
Add new methods to dump_devinfo (#1373)
Adds `getMatterSetupInfo`, `getConnectStatus` and `scanApList`
2024-12-16 13:06:26 +00:00
Steven B.
e206d9b4df
Miscellaneous minor fixes to dump_devinfo (#1382)
Fixes:
 - Decrypted discovery data saved under `discovery_result` instead of `result`
 - `smart` child data not redacted
 - `smartcam` child component list `device_id` not `SCRUBBED`
2024-12-16 13:00:28 +00:00
Steven B.
62345be916
Add timeout parameter to dump_devinfo (#1381) 2024-12-16 13:48:27 +01:00
Steven B.
8cb5c2e180
Update dump_devinfo for raw discovery json and common redactors (#1358)
Some checks failed
CI / Perform linting checks (3.13) (push) Waiting to run
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Blocked by required conditions
CodeQL checks / Analyze (python) (push) Has been cancelled
This PR does a few related things to dump_devinfo:

- Store the raw discovery result in the fixture.
- Consolidate redaction logic so it's not duplicated in dump_devinfo.
- Update existing fixtures to:
  - Store raw discovery result under `result`
  - Use `SCRUBBED_CHILD_DEVICE_ID` everywhere
  - Have correct values as per the consolidated redactors.
2024-12-11 14:18:44 +01:00
Teemu R.
74b59d7f98
Scrub more vacuum keys (#1328) 2024-12-01 18:07:05 +01:00
Teemu R.
9966c6094a
Add ssltransport for robovacs (#943)
This PR implements a clear-text, token-based transport protocol seen on
RV30 Plus (#937).

- Client sends `{"username": "email@example.com", "password":
md5(password)}` and gets back a token in the response
- Rest of the communications are done with POST at `/app?token=<token>`

---------

Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-12-01 18:06:48 +01:00
Teemu R.
d122b48788
Add vacuum component queries to dump_devinfo (#1320) 2024-11-29 19:02:04 +00:00
Steven B.
fe53cd7d9c
Use markdown footnotes in supported.md (#1310)
Brings our markdown inline with the [HA
markdown](https://github.com/home-assistant/home-assistant.io/pull/33342#discussion_r1653484233)
2024-11-25 18:02:12 +01:00
Steven B.
2bda54fcb1
Rename smartcamera to smartcam (#1300) 2024-11-23 09:07:47 +01:00
Steven B.
f4316110c9
Move iot fixtures into iot subfolder (#1299) 2024-11-22 21:19:33 +01:00
Ryan Nitcher
c5830a4cdc
Add PIR ADC Values to Test Fixtures (#1296) 2024-11-22 07:59:17 +00:00
Ryan Nitcher
59b047f485
Add SMART Voltage Monitoring to Fixtures (#1290) 2024-11-20 17:59:09 +00:00
Steven B.
0e5013d4b4
dump_devinfo: iot light strip commands (#1286) 2024-11-20 15:06:59 +01:00
Teemu R.
bbe68a5fe9
dump_devinfo: query smartlife.iot.common.cloud for fw updates (#1284) 2024-11-20 13:07:02 +00:00
Steven B.
bf23f73cce
Extend dump_devinfo iot queries (#1278) 2024-11-20 00:36:16 +01:00
Steven B.
a01247d48f
Remove support for python <3.11 (#1273)
Python 3.11 ships with latest Debian Bookworm. 
pypy is not that widely used with this library based on statistics. It could be added back when pypy supports python 3.11.
2024-11-18 18:46:36 +00:00
Steven B.
e209d40a6d
Use _get_device_info methods for smart and iot devs in devtools (#1265) 2024-11-18 14:53:11 +00:00
Steven B.
5fe75cada9
Add smartcamera devices to supported docs (#1257)
The library now officially supports H200, C200 and TC65
2024-11-14 18:28:30 +00:00
Steven B.
b8f6651d9b
Remove experimental support (#1256) 2024-11-14 15:55:02 +01:00
Steven B.
6213b90f62
Move TAPO smartcamera out of experimental package (#1255)
Co-authored-by: Teemu R. <tpr@iki.fi>
2024-11-13 19:59:42 +00:00
Steven B.
e55731c110
Move protocol modules into protocols package (#1254) 2024-11-13 17:50:21 +00:00
Steven B.
254a9af5c1
Update DiscoveryResult to use Mashumaro instead of pydantic (#1231)
Mashumaro is faster and doesn't come with all versioning problems that
pydantic does.

A basic perf test deserializing all of our discovery results fixtures
shows mashumaro as being about 6 times faster deserializing dicts than
pydantic. It's much faster parsing from a json string but that's likely
because it uses orjson under the hood although that's not really our use
case at the moment.

```
PYDANTIC - ms
=================
json       dict
-----------------
4.7665     1.3268
3.1548     1.5922
3.1130     1.8039
4.2834     2.7606
2.0669     1.3757
2.0163     1.6377
3.1667     1.3561
4.1296     2.7297
2.0132     1.3471
4.0648     1.4105

MASHUMARO - ms
=================
json       dict
-----------------
0.5977     0.5543
0.5336     0.2983
0.3955     0.2549
0.6516     0.2742
0.5386     0.2706
0.6678     0.2580
0.4120     0.2511
0.3836     0.2472
0.4020     0.2465
0.4268     0.2487
```
2024-11-12 22:00:04 +01:00
Teemu R.
668ba748c5
Move transports into their own package (#1247)
This moves all transport implementations into a new `transports` package
for cleaner main package & easier to understand project structure.
2024-11-12 14:40:44 +01:00
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