Commit Graph

832 Commits

Author SHA1 Message Date
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
Teemu R.
486984fff8
Add motion sensor to known categories (#1176)
Also, improve device type warning on unknown devices
2024-10-18 12:31:52 +02:00
Steven B.
2dd621675a
Drop urllib3 dependency and create ssl context in executor thread (#1175) 2024-10-18 11:40:17 +02:00
Steven B.
c6f2d89d44
Expose smart child device map as a class constant (#1173)
To facilitate distinguishing between smart and smart camera child devices.
2024-10-18 09:55:07 +01:00
Steven B.
dcc36e1dfe
Initial TapoCamera support (#1165)
Adds experimental support for the Tapo Camera protocol also used by the H200 hub.
Creates a new SslAesTransport and a derived SmartCamera and SmartCameraProtocol.
2024-10-16 16:53:52 +01:00
Steven B.
380fbb93c3
Enable newer encrypted discovery protocol (#1168) 2024-10-16 15:28:27 +01:00
Steven B.
7fd8c14c1f
Create common Time module and add time set cli command (#1157) 2024-10-15 08:59:25 +01:00
Steven B.
885a04d24f
Prepare 0.7.5 (#1160)
## [0.7.5](https://github.com/python-kasa/python-kasa/tree/0.7.5) (2024-10-08)

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

**Release summary:**

- Fix for KP303 on Firmware 1.0.6
- Fix for `on_since` value jitter
- Various maintenance items

**Breaking changes:**

- Make iot time timezone aware [\#1147](https://github.com/python-kasa/python-kasa/pull/1147) (@sdb9696)

**Fixed bugs:**

- Use tzinfo in time constructor instead of astime for iot devices [\#1158](https://github.com/python-kasa/python-kasa/pull/1158) (@sdb9696)
- Send empty dictionary instead of null for iot queries [\#1145](https://github.com/python-kasa/python-kasa/pull/1145) (@sdb9696)
- Stabilise on\_since value for smart devices [\#1144](https://github.com/python-kasa/python-kasa/pull/1144) (@sdb9696)
- parse\_pcap\_klap: require source host [\#1137](https://github.com/python-kasa/python-kasa/pull/1137) (@rytilahti)
- parse\_pcap\_klap: use request\_uri for matching the response [\#1136](https://github.com/python-kasa/python-kasa/pull/1136) (@rytilahti)


**Project maintenance:**

- Cache zoneinfo for smart devices [\#1156](https://github.com/python-kasa/python-kasa/pull/1156) (@sdb9696)
- Correctly define SmartModule.call as an async function [\#1148](https://github.com/python-kasa/python-kasa/pull/1148) (@sdb9696)
- Remove async magic patch from tests [\#1146](https://github.com/python-kasa/python-kasa/pull/1146) (@sdb9696)
- Move feature initialization from \_\_init\_\_ to \_initialize\_features [\#1140](https://github.com/python-kasa/python-kasa/pull/1140) (@rytilahti)
2024-10-08 13:59:01 +01:00
Steven B.
bd5a24b0ed
Use tzinfo in time constructor instead of astime for iot devices (#1158)
Fixes using `astime` on a non tzinfo aware object which causes issues with daylight saving.
2024-10-08 12:33:19 +01:00
Steven B.
7c1686d3ae
Cache zoneinfo for smart devices (#1156) 2024-10-08 12:21:01 +01:00
Steven B.
9641edcbc0
Make iot time timezone aware (#1147)
Also makes on_since for iot devices use device time.
Changes the return value for device.timezone to be tzinfo instead of a dict.
2024-10-08 08:16:51 +01:00
Steven B.
8bb2cca7cf
Remove async magic patch from tests (#1146)
Not required since AsyncMock available in python 3.8 and probably better
to keep magic to a minimum.
2024-10-02 17:12:10 +02:00
Steven B.
1026e890a1
Correctly define SmartModule.call as an async function (#1148) 2024-10-02 16:00:27 +01:00
Steven B.
1fcf3e44c2
Stabilise on_since value for smart devices (#1144)
Caches the `on_since` value to prevent jitter caused by the device calculations.
2024-10-02 15:04:16 +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
Teemu R.
d897503b58
Move feature initialization from __init__ to _initialize_features (#1140) 2024-09-28 20:14:31 +02:00
Steven B.
2922c3f574
Prepare 0.7.4 (#1135)
## [0.7.4](https://github.com/python-kasa/python-kasa/tree/0.7.4) (2024-09-27)

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

**Release summary:**

- KL135 color temp range corrected to 9000k max
- Minor enhancements and project maintenance

**Implemented enhancements:**

- Add factory\_reset\(\) to iotdevice [\#1125](https://github.com/python-kasa/python-kasa/pull/1125) (@rytilahti)
- Add reboot\(\) to the device interface [\#1124](https://github.com/python-kasa/python-kasa/pull/1124) (@rytilahti)
- Add factory-reset command to cli [\#1108](https://github.com/python-kasa/python-kasa/pull/1108) (@rytilahti)

**Fixed bugs:**

- Extend KL135 ct range up to 9000K [\#1123](https://github.com/python-kasa/python-kasa/pull/1123) (@rytilahti)
- Fix cli command for device off [\#1121](https://github.com/python-kasa/python-kasa/pull/1121) (@sdb9696)

**Project maintenance:**

- Use pytest-socket to ensure no tests are performing io [\#1133](https://github.com/python-kasa/python-kasa/pull/1133) (@sdb9696)
- Enable ruff lint pycodestyle warnings [\#1132](https://github.com/python-kasa/python-kasa/pull/1132) (@sdb9696)
- Add autouse fixture to patch asyncio.sleep [\#1131](https://github.com/python-kasa/python-kasa/pull/1131) (@sdb9696)
- Mock asyncio.sleep for klapprotocol tests [\#1130](https://github.com/python-kasa/python-kasa/pull/1130) (@rytilahti)
- Add fixture for T110 fw 1.9.0 [\#1129](https://github.com/python-kasa/python-kasa/pull/1129) (@rytilahti)
- Speed up and simplify github workflows [\#1128](https://github.com/python-kasa/python-kasa/pull/1128) (@sdb9696)
- Add KS200M\(US\) fw 1.0.12 fixture [\#1127](https://github.com/python-kasa/python-kasa/pull/1127) (@GatorEG)
- Add stale PR/Issue github workflow [\#1126](https://github.com/python-kasa/python-kasa/pull/1126) (@sdb9696)
- Add fixture for KL135\(US\) fw 1.0.15 [\#1122](https://github.com/python-kasa/python-kasa/pull/1122) (@rytilahti)
2024-09-27 18:28:58 +01:00
Teemu R.
1ce5af2494
Add factory_reset() to iotdevice (#1125)
Also extend the base device class API to make factory_reset() part of the common API.
2024-09-27 17:42:22 +01:00
Steven B.
d1b43f5408
Fix cli command for device off (#1121)
Was previously missed when using the full `kasa device off` command as
opposed to the shortcut.
2024-09-27 17:36:45 +01:00
Steven B.
5d78f000c3
Add stale PR/Issue github workflow (#1126) 2024-09-27 17:34:27 +01:00
Steven B.
b4aba36b73
Use pytest-socket to ensure no tests are performing io (#1133) 2024-09-27 17:20:25 +01:00
Steven B.
936e45cad7
Enable ruff lint pycodestyle warnings (#1132)
Addresses repeated SyntaxWarnings when running linters:
```
kasa/tests/test_bulb.py:254: SyntaxWarning: invalid escape sequence '\d'
  ValueError, match="Temperature should be between \d+ and \d+, was 1000"
kasa/tests/test_bulb.py:258: SyntaxWarning: invalid escape sequence '\d'
  ValueError, match="Temperature should be between \d+ and \d+, was 10000"
kasa/tests/test_common_modules.py:216: SyntaxWarning: invalid escape sequence '\d'
  with pytest.raises(ValueError, match="Temperature should be between \d+ and \d+"):
kasa/tests/test_common_modules.py:219: SyntaxWarning: invalid escape sequence '\d'
  with pytest.raises(ValueError, match="Temperature should be between \d+ and \d+"):
```
2024-09-27 17:36:41 +02:00
Steven B.
db686e191a
Add autouse fixture to patch asyncio.sleep (#1131) 2024-09-27 10:57:23 +01:00
Steven B.
038b6993ca
Speed up and simplify github workflows (#1128)
- Enable parallel tests in the CI with pytest-xdist
- Migrate to the official `astral-sh/setup-uv` github action
- Call `pre-commit` run as a single job in CI instead of relisting each
check
- Use `uv` version 0.4.16
- Fix bug with pre-commit cache
- Update `publish.yml` to use  `astral-sh/setup-uv`
2024-09-27 10:27:53 +01:00
Teemu R.
1ab08f454f
Add fixture for T110 fw 1.9.0 (#1129) 2024-09-27 09:35:17 +01:00
Teemu R.
8321fd08aa
Mock asyncio.sleep for klapprotocol tests (#1130)
Speeds up tests in `test_klapprotocol.py` from 26s to 2s when there's no
sleep between the retries.
2024-09-27 09:34:30 +01:00
Ethan G
69c270055d
Add KS200M(US) fw 1.0.12 fixture (#1127) 2024-09-22 22:29:42 +02:00
Teemu R.
89d611d2cd
Add fixture for KL135(US) fw 1.0.15 (#1122)
By courtesy of @jhemak:
https://github.com/home-assistant/core/issues/126300#issuecomment-2364640319
2024-09-21 20:18:55 +02:00
Teemu R.
73b6d16074
Extend KL135 ct range up to 9000K (#1123) 2024-09-21 16:29:25 +01:00
Teemu R.
b7fa0d2040
Add factory-reset command to cli (#1108)
Allow reseting devices to factory settings using the cli: `kasa device factory-reset`.
2024-09-21 16:52:52 +02:00
Teemu R.
f07341a5a6
Add reboot() to the device interface (#1124)
Both device families have already had a method following this signature,
but defining the interface in the base class will make the contract
clear.
2024-09-21 16:37:38 +02:00
Steven B.
5df6c769b8
Prepare 0.7.3 (#1116)
## [0.7.3](https://github.com/python-kasa/python-kasa/tree/0.7.3) (2024-09-10)

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

**Release summary:**

- Migrate from `poetry` to `uv` for package/project management.
- Various minor code improvements

**Project maintenance:**

- Do not regenerate aes key pair [\#1114](https://github.com/python-kasa/python-kasa/pull/1114) (@sdb9696)
- Fix tests due to yarl URL str output change [\#1112](https://github.com/python-kasa/python-kasa/pull/1112) (@sdb9696)
- Add missing type hints to alarm module [\#1111](https://github.com/python-kasa/python-kasa/pull/1111) (@rytilahti)
- Add KH100 EU fixtures [\#1109](https://github.com/python-kasa/python-kasa/pull/1109) (@rytilahti)
- Migrate from poetry to uv for dependency and package management [\#986](https://github.com/python-kasa/python-kasa/pull/986) (@sdb9696)
2024-09-10 17:55:39 +01:00
Steven B.
fcf8f07232
Do not regenerate aes key pair (#1114)
And read it from `device_config` if provided.

This is required as key generation can eat up cpu when a device is not fully available and the library is retrying.
2024-09-10 17:24:38 +01:00
Teemu R.
2a89e58ae0
Add missing type hints to alarm module (#1111) 2024-09-10 17:20:00 +01: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.
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