Commit Graph

843 Commits

Author SHA1 Message Date
Steven B.
a88b677776
Combine smartcamera error codes into SmartErrorCode (#1190)
Having these in a seperate place complicates the code unnecessarily.
2024-10-23 20:07:32 +01:00
Steven B.
a0f3f016a2
Rename experimental fixtures folder to smartcamera (#1191) 2024-10-23 19:26:11 +01:00
Steven B.
cd0a74ca96
Improve supported module checks for hub children (#1188)
No devices in `fixtures/smart/child` support the `get_device_time` or
`get_device_usage` methods so this PR tests for whether the device is a
hub child and marks those modules/methods as not supported. This
prevents features being erroneously created on child devices.

It also moves the logic for getting the time from the parent module
behind getting it from the child module which was masking the creation
of these unsupported modules.
2024-10-23 17:17:27 +02:00
Steven B.
048c84d72c
Add https parameter to device class factory (#1184)
`SMART.TAPOHUB` resolves to different device classes based on the https value
2024-10-22 18:09:35 +01:00
Steven B.
3c865b5fb6
Add try_connect_all to allow initialisation without udp broadcast (#1171)
- Try all valid combinations of protocol/transport/device class and attempt to connect. 
- Add cli command `discover config` to return the connection options after connecting via `try_connect_all`.
- The cli command does not return the actual device for processing as this is not a recommended way to regularly connect to devices.
2024-10-22 14:33:46 +01:00
Steven B.
852116795c
Add discovery list command to cli (#1183)
Report discovered devices in a concise table format.
2024-10-22 12:15:08 +01:00
Steven B.
53fafc3994
Add T110(US), T310(US) and T315(US) sensor fixtures (#1179)
Many thanks to @SirWaddles for the fixtures!
2024-10-18 16:05:53 +02:00
Teemu R.
8d0a5c69ef
Enforce EOLs for *.rst and *.md (#1178)
Looks like everything was fine, but let's do this nevertheless.
2024-10-18 16:03:57 +02:00
Steven B.
d5450d89ff
Add H200 experimental fixture (#1180) 2024-10-18 14:02:08 +01:00
Teemu R.
6ba7c4ac05
Convert fixtures to use unix newlines (#1177)
Also, add a .gitattributes entry to let git handle this automatically
for json files
2024-10-18 14:00:23 +02:00
Teemu R.
8a17752ae2
Add waterleak alert timestamp (#1162)
The T300 reports the timestamp of the last alarm, this exposes it to
consumers.
2024-10-18 13:18:12 +02: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
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