Some tests leave the `kasa` logger at a different level or rename devices
in shared fixture data. Later log assertions and device dump comparisons
then pass or fail depending on the test order.
This PR restores logger levels through `caplog` and renames devices on
copies, so the affected tests pass independently of their order.
In details:
- Use `caplog.set_level` for tests that change the `kasa` logger, and
remove an unused logger override.
- Add an autouse fixture that restores any changed logger levels and
fails the test with a pointer to `caplog.set_level`.
- Rename README devices on deep copies of the fixture data.
- Cover KLAP handshake debug logging explicitly, instead of relying on
an earlier test leaving DEBUG enabled.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Add type annotations (parameter types and `-> None` return types) to all
top-level test functions across 22 test files. This enables mypy to
check test function bodies, catching type errors that were previously
hidden.
Drop the `XorTransport` guard and always query sysinfo for `IotProtocol`
connections, so `get_device_class_from_sys_info` sees `dev_name`
(\"Wi-Fi Smart Dimmer\", etc.) and picks the right class to initialize.
This is necessary, as some IOT-speaking devices have moved to use KLAP
instead of XOR as their transport, which in turn caused devices like dimmers
to be detected incorrectly as plugs.
---------
Co-authored-by: bluntman001 <noreply@github.com>
Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
Some IOT-family devices keep the legacy IOT command set after a firmware
update but upgrade their KLAP authentication to login version 2 (sha256 hashing).
This change selects `KlapTransportV2` for `IOT.KLAP` devices that advertise
`login_version >= 2`, matching the transport already used for `SMART.KLAP`.
Devices with login version 1 (or unset) are unchanged and continue to use the v1 `KlapTransport`.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Update test framework to support `smartcam` device discovery:
- Add `SMARTCAM` to the default `discovery_mock` filter
- Make connection parameter derivation a self contained static method in `Discover`
- Introduce a queue to the `discovery_mock` to ensure the discovery callbacks
complete in the same order that they started.
- Patch `Discover._decrypt_discovery_data` in `discovery_mock`
so it doesn't error trying to decrypt empty fixture data
Adds support for clean module:
- Show current vacuum state
- Start cleaning (all rooms)
- Return to dock
- Pausing & unpausing
- Controlling the fan speed
---------
Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
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>
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
```