Commit Graph

89 Commits

Author SHA1 Message Date
Steven B
ced879498b
Put child fixtures in subfolder (#809)
This should prevent child fixtures from hubs breaking tests due to
missing discovery info. To get these devices in `filter_fixtures`
include protocol string of `SMART.CHILD`.
2024-03-06 15:54:55 +01:00
Steven B
fcad0d2344
Add WallSwitch device type and autogenerate supported devices docs (#758) 2024-03-01 18:32:45 +00:00
Steven B
24344b71f5
Update dump_devinfo to collect child device info (#796)
Will create separate fixture files if the model of the child devices
differs from the parent (i.e. hubs). Otherwise the child device info
will be under `child_devices`
2024-02-28 17:04:57 +01:00
Teemu R
a73e2a9ede
Add H100 fixtures (#737)
One direct out of the box, another with upgraded fw & t315
2024-02-24 00:12:19 +01:00
Benjamin Ness
f965b14021
Add feature for ambient light sensor (#787) 2024-02-22 19:11:30 +01:00
Steven B
8c39e81a40
Rename and deprecate exception classes (#739)
# Public #
SmartDeviceException -> KasaException
UnsupportedDeviceException(SmartDeviceException) -> UnsupportedDeviceError(KasaException)
TimeoutException(SmartDeviceException, asyncio.TimeoutError) -> TimeoutError(KasaException, asyncio.TimeoutError)

Add new exception for error codes -> DeviceError(KasaException)
AuthenticationException(SmartDeviceException) -> AuthenticationError(DeviceError)

# Internal #
RetryableException(SmartDeviceException) -> _RetryableError(DeviceError)
ConnectionException(SmartDeviceException) -> _ConnectionError(KasaException)
2024-02-21 16:52:55 +01:00
Teemu R
e86dcb6bf5
Fix dump_devinfo scrubbing for ks240 (#765) 2024-02-19 00:08:39 +01:00
Steven B
57835276e3
Fix devtools for P100 and add fixture (#753) 2024-02-14 19:43:10 +00:00
Steven B
0d119e63d0
Refactor devices into subpackages and deprecate old names (#716)
* Refactor devices into subpackages and deprecate old names

* Tweak and add tests

* Fix linting

* Remove duplicate implementations affecting project coverage

* Update post review

* Add device base class attributes and rename subclasses

* Rename Module to BaseModule

* Remove has_emeter_history

* Fix missing _time in init

* Update post review

* Fix test_readmeexamples

* Fix erroneously duped files

* Clean up iot and smart imports

* Update post latest review

* Tweak Device docstring
2024-02-04 16:20:08 +01:00
Teemu R
1acf4e86da
Retain last two chars for children device_id (#733) 2024-02-01 19:27:01 +01:00
Steven B
0d0f56414c
Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport (#710)
* Switch from TPLinkSmartHomeProtocol to IotProtocol/XorTransport

* Add test

* Update docs

* Fix ruff deleting deprecated import
2024-01-26 09:11:31 +00:00
Steven B
f7c04bcef8
Add --batch-size hint to timeout errors in dump_devinfo (#696)
* Add --batch-size hint to timeout errors in dump_devinfo

* Add _echo_error function for displaying critical errors
2024-01-24 10:40:36 +01:00
Teemu R
3f40410db3
Update readme fixture checker and readme (#699) 2024-01-24 09:36:45 +01:00
Steven B
1db955b05e
Make request batch size configurable and avoid multiRequest if 1 (#681) 2024-01-23 11:33:07 +01:00
Teemu R
c1f2f8fe67
Check README for supported models (#684)
* Check README for supported models

* Use poetry for running due to imports

* Update README
2024-01-23 10:14:59 +00:00
Teemu R
f77e87dc5d
dump_devinfo improvements (#657)
* dump_devinfo improvements

* Scrub only the last three bytes for mac addresses
* Add --target to allow creating fixtures based on discovery
* Save fixtures directly to correct location, add --basedir to allow defining the location of repository root
* Add --autosave to disable prompting for saving

* Update fixtures for devices I have

* Add fixture for HS110 hw 4.0 fw 1.0.4

* Improve help strings

* Fix tests

* Update devtools README

* Default to discovery if no host/target given
2024-01-20 14:20:08 +01:00
Steven B
3b1b0a3c21
Encapsulate http client dependency (#642)
* Encapsulate http client dependency

* Store cookie dict as variable

* Update post-review
2024-01-18 10:57:33 +01:00
Steven B
897db674c2
Add L900-10 fixture and it's additional component requests (#629) 2024-01-10 19:40:36 +01:00
Teemu R
7e6eaf4ab2
Use consistent envvars for dump_devinfo credentials (#618) 2024-01-04 19:28:59 +01:00
sdb9696
ae5ad3e8c6
Add known smart requests to dump_devinfo (#597)
* Add known smart requests to dump_devinfo

* Move smartrequest.py to devtools

* Update post-review
2024-01-02 18:20:53 +01:00
sdb9696
1b7914277d
Fix dump_devinfo for unauthenticated (#593) 2023-12-29 20:42:02 +01:00
sdb9696
b27a31a8a9
Add new methods to dump_devinfo and mask aliases (#574) 2023-12-08 14:29:07 +01:00
Teemu R
f9b5003da2
Add support for tapo bulbs (#558)
* Add support for tapo light bulbs

* Use TapoDevice for on/off

* Add tapobulbs to discovery

* Add partial support for effects

Activating the effect does not work as I thought it would,
but this implements rest of the interface from SmartLightStrip.

* Add missing __init__ for tapo package

* Make mypy happy

* Add docstrings to make ruff happy

* Implement state_information and has_emeter

* Import tapoplug from kasa.tapo package

* Add tapo L530 fixture

* Enable tests for L530 fixture

* Make ruff happy

* Update fixture filename

* Raise exceptions on invalid parameters

* Return results in a wrapped dict

* Implement set_*

* Reorganize bulbs to iot&smart, fix tests for smarts

* Fix linting

* Fix BULBS_LIGHT_STRIP back to LIGHT_STRIPS
2023-12-05 20:07:10 +01:00
sdb9696
5e2fcd2cca
Re-add regional suffix to TAPO/SMART fixtures (#566) 2023-12-05 16:45:09 +01:00
sdb9696
a6b7d73d79
Update dump_devinfo to produce new TAPO/SMART fixtures (#561) 2023-12-02 17:33:35 +01:00
sdb9696
9de3f69033
Update dump_devinfo to include 20002 discovery results (#556)
* Fix dump_devinfo and add discovery_result to json

* Update following review.  Do not serialize aliases.

* Delete kasa/tests/fixtures/HS100(UK)_1.0_1.2.6.json
2023-11-29 20:01:20 +01:00
Teemu R
c431dbb832
Use ruff and ruff format (#534)
Replaces the previously used linting and code formatting tools with ruff.
2023-10-29 23:15:42 +01:00
Teemu R
fad6ae5d10
Add devtools script to create module fixtures (#404) 2023-08-27 19:53:36 +02:00
J. Nick Koston
fde156c859
Add benchmarks for speedups (#473)
* Add benchmarks for speedups

* Update README.md

* Update README.md

Co-authored-by: Teemu R. <tpr@iki.fi>

* relo

* Update README.md

* document benchmark

* Update README.md

---------

Co-authored-by: Teemu R. <tpr@iki.fi>
2023-07-02 01:03:50 +02:00
Teemu R
02c857d472
Some release preparation janitoring (#432)
* Use myst-parser for readme.md doc injection

* Relax version pins

* Define bug tracker and doc links for pypi

* Update pre-commit hooks
2023-02-18 22:09:35 +01:00
Teemu R
dd044130d4
Use rich for prettier output, if available (#403)
Use rich for prettier output, if available.

This does not add a new dependency, but rather uses rich if it's installed.
2023-02-18 17:31:06 +01:00
mrbetta
5bf6fda7ee
Added a fixture file for KS220M (#273)
* Added motion and light sensor for KS220M

* Added fixture file for ks220m

* Remove dump_devinfo and add the extra queries to devtools/dump_devinfo

* Test KS220M as a dimmer

* Add empty modules to baseproto to make the tests pass

Co-authored-by: mrbetta <bettale@gmail.com>
Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2022-01-29 18:28:14 +01:00
Teemu R
8a4068c623
Add script to check supported devices, update README (#242)
* check_readme_vs_fixtures.py checks if a device with a fixture is listed in the README
* Add missing entries to README.md
2021-10-25 10:17:35 +03:00
Teemu R
d75e1adaba
Add perftest to devtools (#236)
* Add perftest to devtools

* Add example output from the perf script

* Rename to avoid pytest collection

* Fix git mv failing to remove the original file..
2021-10-13 19:22:24 +02:00
J. Nick Koston
e31cc6662c
Keep connection open and lock to prevent duplicate requests (#213)
* Keep connection open and lock to prevent duplicate requests

* option to not update children

* tweaks

* typing

* tweaks

* run tests in the same event loop

* memorize model

* Update kasa/protocol.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update kasa/protocol.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update kasa/protocol.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update kasa/protocol.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* dry

* tweaks

* warn when the event loop gets switched out from under us

* raise on unable to connect multiple times

* fix patch target

* tweaks

* isrot

* reconnect test

* prune

* fix mocking

* fix mocking

* fix test under python 3.7

* fix test under python 3.7

* less patching

* isort

* use mocker to patch

* disable on old python since mocking doesnt work

* avoid disconnect/reconnect cycles

* isort

* Fix hue validation

* Fix latitude_i/longitude_i units

Co-authored-by: Teemu R. <tpr@iki.fi>
2021-09-24 23:25:43 +02:00
Teemu R
799032a8df
dump_devinfo: handle latitude/longitude keys properly (#175)
* also, -d/--debug is now a flag
2021-06-19 22:46:36 +03:00
Teemu R
0471e1a5a8
Simplify discovery query, refactor dump-devinfo (#147)
* Use only system:get_sysinfo for discovery

* move dump-devinfo into a separate tool under devtools

* Fix linting
2021-05-10 02:19:00 +02:00
Teemu R
1ee4757fdb
Return None instead of raising an exception on missing, valid emeter keys (#146)
Fixes #142

Also, update the pre-commit hooks to their newest versions
2021-03-18 19:22:10 +01:00
Teemu R
713b443dd0
Add parse_pcap to devtools, improve readme on contributing (#84)
* Add parse_pcap to devtools, improve readme on contributing

* simplify context extraction
2020-07-12 23:07:24 +02:00