Commit Graph

590 Commits

Author SHA1 Message Date
Steven B.
f7778aaa53
Migrate RuleModule to mashumaro (#1283)
Also fixes a bug whereby multiple queries for the same module would overwrite each other.
2024-11-20 14:59:32 +00:00
Steven B.
955e7ab4d0
Migrate TurnOnBehaviours to mashumaro (#1285) 2024-11-20 15:35:51 +01:00
Steven B.
5eca487bcb
Migrate iot cloud module to mashumaro (#1282)
Breaking change as the CloudInfo interface is changing to snake case for
consistency with the rest of the library.
2024-11-20 14:34:26 +01:00
Steven B.
df48c21900
Migrate triggerlogs to mashumaru (#1277) 2024-11-20 13:21:08 +00:00
Steven B.
999e84d2de
Migrate smart firmware module to mashumaro (#1276) 2024-11-20 11:54:13 +00:00
Steven B.
03c073c293
Migrate IotLightPreset to mashumaru (#1275) 2024-11-20 08:37:04 +00:00
Steven B.
79ac9547e8
Replace custom deviceconfig serialization with mashumaru (#1274) 2024-11-20 08:35:32 +00:00
Steven B.
2683623997
Update DiscoveryResult to use mashu Annotated Alias (#1279) 2024-11-19 19:09:50 +00:00
Steven B.
5b5a148f9a
Add pan tilt camera module (#1261)
Add ptz controls for smartcameras.

---------

Co-authored-by: Teemu R. <tpr@iki.fi>
2024-11-19 10:11:51 +00: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.
0c40939624
Allow callable coroutines for feature setters (#1272) 2024-11-18 14:53:49 +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.
9d46996e9b
Fix repr for device created with no sysinfo or discovery info" (#1266)
Co-authored-by: Teemu R. <tpr@iki.fi>
2024-11-18 13:14:39 +00:00
Steven B.
fd5258c28b
Fix discovery by alias for smart devices (#1260)
Fixes #1259
2024-11-18 13:03:13 +00:00
Steven B.
410c3d2623
Fix deprecated SSLContext() usage (#1271) 2024-11-18 12:49:44 +01:00
Steven B.
0d1193ac71
Update cli feature command for actions not to require a value (#1264) 2024-11-15 14:38:41 +00:00
Steven B.
cf77128853
Add alarm module for smartcamera hubs (#1258) 2024-11-15 11:19:40 +01: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
Teemu R.
a82ee56a27
Fix warnings in our test suite (#1246)
Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
2024-11-13 16:10:06 +00:00
Steven B.
157ad8e807
Update cli energy command to use energy module (#1252) 2024-11-13 15:57:42 +01:00
Steven B.
3086aa8a20
Use component queries to select smartcamera modules (#1248) 2024-11-13 10:21:12 +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
Steven B.
9d5e07b969
Add SmartCamera Led Module (#1249) 2024-11-12 19:34:02 +00: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.
71ae06fa83
Fix test framework running against real devices (#1235) 2024-11-11 17:41:31 +00:00
Steven B.
32671da9e9
Move tests folder to top level of project (#1242) 2024-11-11 10:11:31 +00:00
Teemu R.
e5dd874333
Update fixture for ES20M 1.0.11 (#1215) 2024-11-11 09:31:13 +00:00
Teemu R.
66eb17057e
Enable ruff check for ANN (#1139) 2024-11-10 18:55:13 +00:00
Teemu R.
24d7b8612e
Add L630 fixture (#1240) 2024-11-10 13:56:14 +00:00
Puxtril
4e9a3e6b02
Print formatting for IotLightPreset (#1216)
Now prints presets as such:

```
[0] Hue:   0  Saturation:   0  Brightness/Value: 100  Temp: 6000  Custom: None  Mode: None  Id: None
[1] Hue:   0  Saturation:   0  Brightness/Value: 100  Temp: 2500  Custom: None  Mode: None  Id: None
[2] Hue:   0  Saturation:   0  Brightness/Value:  60  Temp: 2500  Custom: None  Mode: None  Id: None
[3] Hue: 240  Saturation: 100  Brightness/Value: 100  Temp:    0  Custom: None  Mode: None  Id: None
```
2024-11-09 18:03:06 +01:00
Ryan Nitcher
857a706649
Add Additional Firmware Test Fixures (#1234)
Fixtures for the following new firmware versions on existing devices:

- ES20M(US)_1.0_1.0.11
- HS200(US)_3.0_1.1.5
- HS200(US)_5.0_1.0.11
- HS210(US)_2.0_1.1.5
- KP303(US)_2.0_1.0.9
- KS200M(US)_1.0_1.0.10
- KP125M(US)_1.0_1.2.3
- KS240(US)_1.0_1.0.7
2024-11-09 07:16:41 +00:00
Ryan Nitcher
a4df014328
Add KS220 Fixture (#1237)
Add Fixture for
[KS220](https://www.kasasmart.com/us/products/smart-switches/kasa-smart-wifi-light-switch-dimmer-ks220),
Smart Wi-Fi Light Switch, Dimmer (HomeKit).
2024-11-09 02:50:21 +01:00
Ryan Nitcher
6039760186
Add EP40M Fixture (#1238)
Add fixture for
[EP40M](https://www.kasasmart.com/us/products/smart-plugs/smart-wifi-outdoor-plug-ep40m),
Smart Wi-Fi Outdoor Plug (Matter).
2024-11-09 01:47:56 +01:00
Teemu R.
4026e8a80c
Make __repr__ work on discovery info (#1233)
This PR will make `__repr__` also work on smartdevices where only
discovery data is available by modifying the `model` property to
fallback to the data found in the discovery payloads.
2024-11-07 20:09:51 +01:00
Teemu R.
b2f3971a4c
Add PIR&LAS for wall switches mentioning PIR support (#1227)
Some devices (like KS200M) support ambient and motion, but as they are
detected as wall switches, they don't get the modules added.
This PR enables the respective modules for wall switches when the
`dev_name` contains `PIR`.
2024-11-03 16:45:48 +01:00
Teemu R.
0360107e3f
Add childprotection module (#1141)
When turned on, rotating the thermostat will not change the target
temperature.
2024-11-01 20:46:36 +01:00
Steven B.
77b654a9aa
Update try_connect_all to be more efficient and report attempts (#1222) 2024-11-01 18:17:18 +00:00
Teemu R.
70c96b5a5d
Initial trigger logs implementation (#900)
Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-11-01 15:36:09 +00:00
Teemu R.
8969b54b87
Update TC65 fixture (#1225) 2024-11-01 15:17:52 +00:00
Steven B.
7335a7d33f
Update smartcamera fixtures from latest dump_devinfo (#1224) 2024-11-01 15:15:13 +00:00
Steven B.
54f0e91c04
Add component queries to smartcamera devices (#1223) 2024-11-01 14:52:39 +00:00
Steven B.
e73da5b677
Fix AES child device creation error (#1220)
Bug exposed when passing credentials_hash and creating child devices for
klap devices as the default is to try to create an AES transport and the
credentials hashes are incompatible.
2024-10-31 15:21:54 +00:00
Teemu R.
5da41fcc11
Use stacklevel=2 for warnings to report on callsites (#1219)
Use stacklevel=2 for warnings, as this will correctly show the callsite
instead of the line where the warning is reported.

Currently:
```
kasa/__init__.py:110
  /home/tpr/code/python-kasa/kasa/__init__.py:110: DeprecationWarning: SmartDevice is deprecated, use IotDevice from package kasa.iot instead or use Discover.discover_single() and Device.connect() to support new protocols
    warn(
```

After:
```
kasa/tests/smart/modules/test_contact.py:3
  /home/tpr/code/python-kasa/kasa/tests/smart/modules/test_contact.py:3: DeprecationWarning: SmartDevice is deprecated, use IotDevice from package kasa.iot instead or use Discover.discover_single() and Device.connect() to support new protocols
    from kasa import Module, SmartDevice

``` 

Currently:
```
kasa/tests/test_lightstrip.py: 56 warnings
  /home/tpr/code/python-kasa/kasa/device.py:559: DeprecationWarning: effect is deprecated, use: Module.LightEffect in device.modules instead
    warn(msg, DeprecationWarning, stacklevel=1)
```

After:
```
kasa/tests/test_lightstrip.py::test_effects_lightstrip_set_effect_transition[500-KL430(US)_2.0_1.0.9.json]
  /home/tpr/code/python-kasa/kasa/tests/test_lightstrip.py:62: DeprecationWarning: set_effect is deprecated, use: Module.LightEffect in device.modules instead
    await dev.set_effect("Candy Cane")
```
2024-10-31 14:12:17 +01:00
Teemu R.
6c141c3b65
Expose ambient light setting for iot dimmers (#1210)
This PR adds a setting to control the ambient light enabled/disabled.

Also fixes the getters.
2024-10-31 12:17:18 +01:00
Teemu R.
9975bbf26a
Expose PIR enabled setting for iot dimmers (#1174)
This adds PIR enabled feature to iot dimmers, making it possible to
enable and disable the motion detection.
2024-10-31 10:41:11 +00:00
Steven B.
673a32258f
Make HSV NamedTuple creation more efficient (#1211) 2024-10-29 17:14:52 +00:00
Steven B.
6d8dc1cc5f
Only send 20002 discovery request with key included (#1207) 2024-10-29 16:21:24 +00:00