Commit Graph

796 Commits

Author SHA1 Message Date
Steven B.
a967d5cd3a
Migrate from poetry to uv for dependency and package management (#986) 2024-09-06 15:48:43 +01:00
Steven B.
1773f98aad
Fix tests due to yarl URL str output change (#1112)
Latest versions of yarl>=1.9.5 omit the port 80 when calling str(url) which broke tests.
2024-09-06 15:27:23 +01:00
Teemu R.
b0d0c4b703
Add KH100 EU fixtures (#1109) 2024-09-06 14:46:44 +02:00
Steven B.
4ef7306332
Prepare 0.7.2 (#1107)
## [0.7.2](https://github.com/python-kasa/python-kasa/tree/0.7.2) (2024-08-30)

[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.7.1...0.7.2)

**Release summary:**

- **Breaking** change to disable including the check for the latest firmware for tapo devices and newer kasa devices in the standard update cycle. To check for the latest firmware call `check_latest_firmware` on the firmware module or run the `check_latest_firmware` feature.
- Minor bugfixes and improvements.

**Breaking changes:**

- Disable automatic updating of latest firmware [\#1103](https://github.com/python-kasa/python-kasa/pull/1103) (@sdb9696)

**Implemented enhancements:**

- Improve performance of dict merge code [\#1097](https://github.com/python-kasa/python-kasa/pull/1097) (@bdraco)

**Fixed bugs:**

- Fix logging in iotdevice when a module is module not supported [\#1100](https://github.com/python-kasa/python-kasa/pull/1100) (@bdraco)

**Documentation updates:**

- Fix incorrect docs link in contributing.md [\#1099](https://github.com/python-kasa/python-kasa/pull/1099) (@sdb9696)

**Project maintenance:**

- Add flake8-pytest-style \(PT\) for ruff [\#1105](https://github.com/python-kasa/python-kasa/pull/1105) (@rytilahti)
- Add flake8-logging \(LOG\) and flake8-logging-format \(G\) for ruff [\#1104](https://github.com/python-kasa/python-kasa/pull/1104) (@rytilahti)
- Add missing typing\_extensions dependency [\#1101](https://github.com/python-kasa/python-kasa/pull/1101) (@sdb9696)
- Remove top level await xdoctest fixture [\#1098](https://github.com/python-kasa/python-kasa/pull/1098) (@sdb9696)
- Enable python 3.13, allow pre-releases for CI [\#1086](https://github.com/python-kasa/python-kasa/pull/1086) (@rytilahti)
2024-08-30 18:55:36 +01:00
Steven B.
520b9d7a38
Disable automatic updating of latest firmware (#1103)
To resolve issues with the calls to the tplink cloud to get the latest firmware.
Disables the automatic calling of `get_latest_fw` and requires firmware update checks to be triggered manually.
2024-08-30 18:01:54 +01:00
Teemu R.
6a86ffbbba
Add flake8-pytest-style (PT) for ruff (#1105)
This will catch common issues with pytest code.

* Use `match` when using `pytest.raises()` for base exception types like
`TypeError` or `ValueError`
* Use tuples for `parametrize()`
* Enforces `pytest.raises()` to contain simple statements, using `noqa`
to skip this on some cases for now.
* Fixes incorrect exception type (valueerror instead of typeerror) for
iotdimmer.
* Adds check valid types for `iotbulb.set_hsv` and `color` smart module.
* Consolidate exception messages for common interface modules.
2024-08-30 17:30:07 +02:00
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.
2706e9a5be
Add missing typing_extensions dependency (#1101) 2024-08-23 19:23:10 +01:00
J. Nick Koston
b6339be9ec
Fix logging in iotdevice when a module is module not supported (#1100)
Debug logger was generating the `repr()` of each module and throwing it away because it had a `%` instead of a `,`
2024-08-23 10:56:33 +01:00
Steven B.
beb7ca2242
Fix incorrect docs link in contributing.md (#1099) 2024-08-22 17:15:04 +02:00
Steven B.
ae1ee388f6
Remove top level await xdoctest fixture (#1098)
This is now natively supported since [xdoctest
#158](https://github.com/Erotemic/xdoctest/pull/158) has been released
so no need for the monkey patching fixture anymore.
2024-08-22 17:14:47 +02:00
J. Nick Koston
4669e08605
Improve performance of dict merge code (#1097)
Co-authored-by: Teemu R. <tpr@iki.fi>
2024-08-14 16:33:54 -05:00
Teemu R.
633f57dcce
Enable python 3.13, allow pre-releases for CI (#1086)
Adds py3.13 to the CI.

Thanks to @hugovk for [pointing out `allow-prereleases` on his blog
post](https://dev.to/hugovk/help-test-python-313-14j1)!

---------

Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-08-06 21:03:35 +02:00
Steven B.
145a16db4c
Prepare 0.7.1 (#1094)
## [0.7.1](https://github.com/python-kasa/python-kasa/tree/0.7.1) (2024-07-31)

[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.7.0.5...0.7.1)

**Release highlights:**
- This release consists mainly of bugfixes and project improvements.
- There is also new support for Tapo T100 motion sensors.
- The CLI now supports child devices on all applicable commands.

**Implemented enhancements:**

- Expose reboot action [\#1073](https://github.com/python-kasa/python-kasa/pull/1073) (@rytilahti)
- Decrypt KLAP data from PCAP files [\#1041](https://github.com/python-kasa/python-kasa/pull/1041) (@clstrickland)
- Support child devices in all applicable cli commands [\#1020](https://github.com/python-kasa/python-kasa/pull/1020) (@sdb9696)

**Fixed bugs:**

- Fix iot light effect brightness [\#1092](https://github.com/python-kasa/python-kasa/pull/1092) (@sdb9696)
- Enable setting brightness with color temp for smart devices [\#1091](https://github.com/python-kasa/python-kasa/pull/1091) (@sdb9696)
- Do not send light\_on value to iot bulb set\_state [\#1090](https://github.com/python-kasa/python-kasa/pull/1090) (@sdb9696)
- Allow erroring modules to recover [\#1080](https://github.com/python-kasa/python-kasa/pull/1080) (@sdb9696)
- Raise KasaException on decryption errors [\#1078](https://github.com/python-kasa/python-kasa/pull/1078) (@sdb9696)
- Update smart request parameter handling [\#1061](https://github.com/python-kasa/python-kasa/pull/1061) (@sdb9696)
- Fix light preset module when list contains lighting effects [\#1048](https://github.com/python-kasa/python-kasa/pull/1048) (@sdb9696)
- Handle module errors more robustly and add query params to light preset and transition [\#1036](https://github.com/python-kasa/python-kasa/pull/1036) (@sdb9696)
- Fix credential hash to return None on empty credentials [\#1029](https://github.com/python-kasa/python-kasa/pull/1029) (@sdb9696)

**Added support for devices:**

- Add support for T100 motion sensor [\#1079](https://github.com/python-kasa/python-kasa/pull/1079) (@rytilahti)

**Project maintenance:**

- Bump project version to 0.7.0.5 [\#1087](https://github.com/python-kasa/python-kasa/pull/1087) (@sdb9696)
- Fix generate\_supported pre commit to run in venv [\#1085](https://github.com/python-kasa/python-kasa/pull/1085) (@sdb9696)
- Fix intermittently failing decryption error test [\#1082](https://github.com/python-kasa/python-kasa/pull/1082) (@sdb9696)
- Fix mypy pre-commit hook on windows [\#1081](https://github.com/python-kasa/python-kasa/pull/1081) (@sdb9696)
- Update RELEASING.md for patch releases [\#1076](https://github.com/python-kasa/python-kasa/pull/1076) (@sdb9696)
- Use monotonic time for query timing [\#1070](https://github.com/python-kasa/python-kasa/pull/1070) (@sdb9696)
- Fix parse\_pcap\_klap on windows and support default credentials [\#1068](https://github.com/python-kasa/python-kasa/pull/1068) (@sdb9696)
- Add fixture file for KP405 fw 1.0.6 [\#1063](https://github.com/python-kasa/python-kasa/pull/1063) (@daleye)
- Bump project version to 0.7.0.3 [\#1053](https://github.com/python-kasa/python-kasa/pull/1053) (@sdb9696)
- Add KP400\(US\) v1.0.4 fixture [\#1051](https://github.com/python-kasa/python-kasa/pull/1051) (@gimpy88)
- Add new HS220 kasa aes fixture [\#1050](https://github.com/python-kasa/python-kasa/pull/1050) (@sdb9696)
- Add KS205\(US\) v1.1.0 fixture [\#1049](https://github.com/python-kasa/python-kasa/pull/1049) (@gimpy88)
- Add KS200M\(US\) v1.0.11 fixture [\#1047](https://github.com/python-kasa/python-kasa/pull/1047) (@sdb9696)
- Add KS225\(US\) v1.1.0 fixture [\#1046](https://github.com/python-kasa/python-kasa/pull/1046) (@sdb9696)
- Split out main cli module into lazily loaded submodules [\#1039](https://github.com/python-kasa/python-kasa/pull/1039) (@sdb9696)
- Structure cli into a package [\#1038](https://github.com/python-kasa/python-kasa/pull/1038) (@sdb9696)
- Add KP400 v1.0.3 fixture [\#1037](https://github.com/python-kasa/python-kasa/pull/1037) (@gimpy88)
- Add L920\(EU\) v1.1.3 fixture [\#1031](https://github.com/python-kasa/python-kasa/pull/1031) (@rytilahti)
- Update changelog generator config [\#1030](https://github.com/python-kasa/python-kasa/pull/1030) (@sdb9696)
2024-07-31 19:02:53 +01:00
Steven B.
6f14330e09
Update RELEASING.md for patch releases (#1076) 2024-07-31 17:56:06 +01:00
Steven B.
31ec27c1c8
Fix iot light effect brightness (#1092)
Fixes issue where the brightness of the `iot` light effect is set properly
on the light effect but read back incorrectly from the light.
2024-07-31 15:58:48 +01:00
Steven B.
cb0077f634
Do not send light_on value to iot bulb set_state (#1090)
Passing this extra value caused the `ignore_default` check in the `IotBulb._set_light_state`
method to fail which causes the device to come back on to the default state.
2024-07-31 15:56:07 +01:00
Steven B.
cb7e904d30
Enable setting brightness with color temp for smart devices (#1091) 2024-07-31 15:52:27 +01:00
Steven B.
7bba9926ed
Allow erroring modules to recover (#1080)
Re-query failed modules after some delay instead of immediately disabling them.
Changes to features so they can still be created when modules are erroring.
2024-07-30 19:23:07 +01:00
Steven B.
445f74eed7
Merge patch into master (#1088) 2024-07-29 12:28:48 +01:00
Steven B
9076e79f07
Merge patch into local master 2024-07-29 11:27:40 +01:00
Steven B.
60be6e03b7
Bump project version to 0.7.0.5 (#1087) 2024-07-29 10:51:21 +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.
1c83675e57
Fix intermittently failing decryption error test (#1082) 2024-07-24 18:58:37 +01:00
Teemu R.
055bbcc0c9
Add support for T100 motion sensor (#1079)
Add support for T100 motion sensor.
Thanks to @DarthSonic for the fixture file!
2024-07-24 15:48:33 +02:00
Teemu R.
dc0aedad20
Expose reboot action (#1073)
Expose reboot through the feature interface.
This can be useful in situations where one wants to reboot the device,
e.g., in recent cases where frequent update calls will render the device
unresponsive after a specific amount of time.
2024-07-24 15:47:38 +02:00
Steven B.
ed033679e5
Split out main cli module into lazily loaded submodules (#1039) 2024-07-23 19:13:52 +01:00
Steven B.
58afeb28a1
Update smart request parameter handling (#1061)
Changes to the smart request handling:
- Do not send params if null
- Drop the requestId parameter
- get_preset_rules doesn't send parameters for preset component version less than 3
- get_led_info no longer sends the wrong parameters
- get_on_off_gradually_info no longer sends an empty {} parameter
2024-07-23 19:02:20 +01: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.
7266d70223
0.7.0.5 (#1077)
## [0.7.0.5](https://github.com/python-kasa/python-kasa/tree/0.7.0.5) (2024-07-18)

[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.7.0.4...0.7.0.5)

A critical bugfix for an issue with some L530 Series devices and a redactor for sensitive info from debug logs.

**Fixed bugs:**

- Only refresh smart LightEffect module daily [\#1064](https://github.com/python-kasa/python-kasa/pull/1064)

**Project maintenance:**

- Redact sensitive info from debug logs [\#1069](https://github.com/python-kasa/python-kasa/pull/1069)
2024-07-18 16:43:28 +01:00
sdb9696
82cff1346d
Prepare 0.7.0.5 2024-07-18 09:47:37 +01:00
Steven B
c4a9a19d5b
Redact sensitive info from debug logs (#1069)
Redacts sensitive data when debug logging device responses such as mac,
location and usernames
2024-07-18 09:47:34 +01:00
Steven B
a97d2c92bb
Only refresh smart LightEffect module daily (#1064)
Fixes an issue with L530 bulbs on HW version 1.0 whereby the light effect
query causes the device to crash with JSON_ENCODE_FAIL_ERROR after
approximately 60 calls.
2024-07-18 09:47:14 +01: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.
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
Steven B.
e17ca21a83
Only refresh smart LightEffect module daily (#1064)
Fixes an issue with L530 bulbs on HW version 1.0 whereby the light effect
query causes the device to crash with JSON_ENCODE_FAIL_ERROR after
approximately 60 calls.
2024-07-17 08:28:11 +01: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
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
daleye
a2b7daa069
Add fixture file for KP405 fw 1.0.6 (#1063) 2024-07-14 16:31:31 +02:00
Steven B
84192a0d77
Bump version to 0.7.0.4 (#1060) 2024-07-12 17:45:37 +01:00
Steven B
448efd7e4c
Prepare 0.7.0.4 (#1059)
## [0.7.0.4](https://github.com/python-kasa/python-kasa/tree/0.7.0.4) (2024-07-011)

[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.7.0.3...0.7.0.4)

Critical bugfixes for issues with P100s and thermostats.

**Fixed bugs:**

- Use first known thermostat state as main state (pick #1054) [\#1057](https://github.com/python-kasa/python-kasa/pull/1057)
- Defer module updates for less volatile modules (pick 1052) [\#1056](https://github.com/python-kasa/python-kasa/pull/1056)
2024-07-11 17:30:14 +01:00
Steven B
377fa06d39
Use first known thermostat state as main state (pick #1054) (#1057)
Pick commit a044063526 from #1054 

Instead of trying to use the first state when multiple are reported,
iterate over the known states and pick the first matching.
This will fix an issue where the device reports extra states (like
`low_battery`) while having a known mode active.

Related to home-assistant/core#121335
2024-07-11 17:05:40 +01:00
Steven B
5dac092227
Defer module updates for less volatile modules (pick 1052) (#1056)
Pick commit 7fd5c213e6 from 1052

Addresses stability issues on older hw device versions

 - Handles module timeout errors better by querying modules individually on errors and disabling problematic modules like Firmware that go out to the internet to get updates.
- Addresses an issue with the Led module on P100 hardware version 1.0 which appears to have a memory leak and will cause the device to crash after approximately 500 calls.
- Delays updates of modules that do not have regular changes like LightPreset and LightEffect and enables them to be updated on the next update cycle only if required values have changed.
2024-07-11 16:54:15 +01:00
Steven B
7fd5c213e6
Defer module updates for less volatile modules (#1052)
Addresses stability issues on older hw device versions

 - Handles module timeout errors better by querying modules individually on errors and disabling problematic modules like Firmware that go out to the internet to get updates.
- Addresses an issue with the Led module on P100 hardware version 1.0 which appears to have a memory leak and will cause the device to crash after approximately 500 calls.
- Delays updates of modules that do not have regular changes like LightPreset and LightEffect and enables them to be updated on the next update cycle only if required values have changed.
2024-07-11 16:21:59 +01:00
Teemu R
a044063526
Use first known thermostat state as main state (#1054)
Instead of trying to use the first state when multiple are reported,
iterate over the known states and pick the first matching.
This will fix an issue where the device reports extra states (like
`low_battery`) while having a known mode active.

Related to https://github.com/home-assistant/core/issues/121335
2024-07-11 15:11:50 +02:00
Steven B
239b5dd267
Bump project version to 0.7.0.3 (#1053) 2024-07-11 14:26:33 +02:00
gimpy88
abb5d0d412
Add KP400(US) v1.0.4 fixture (#1051) 2024-07-07 14:23:24 +02:00
Steven B
4b77db31d0
Add new HS220 kasa aes fixture (#1050)
Many thanks to @pjarbit for making the device available for a fixture!
2024-07-07 14:22:43 +02:00
gimpy88
6e0bbd8720
Add KS205(US) v1.1.0 fixture (#1049) 2024-07-07 09:16:07 +01:00