Commit Graph

610 Commits

Author SHA1 Message Date
J. Nick Koston
fa94548723 Add additional L900-10 fixture (#707) 2024-01-25 08:53:43 +01:00
J. Nick Koston
fa6bc59b29 Replace rich formatting stripper (#706)
* Revert "Fix overly greedy _strip_rich_formatting (#703)"

This reverts commit ae6a31463e.

* Improve rich formatter stripper

reverts and replaces #703
2024-01-25 08:49:26 +01:00
J. Nick Koston
8947ffbc94 Add L930-5 fixture (#694)
* Add L930-5 fixture

* Mark L930-5 as variable temp

* Update readme

* Fix overly greedy _strip_rich_formatting

---------

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2024-01-24 22:31:01 +00:00
J. Nick Koston
3235ba620d Add updated L920 fixture (#680)
* Add updated L920 fixture

* Fix overly greedy _strip_rich_formatting

---------

Co-authored-by: Teemu R <tpr@iki.fi>
2024-01-24 22:29:55 +00:00
J. Nick Koston
ae6a31463e Fix overly greedy _strip_rich_formatting (#703) 2024-01-24 11:53:28 -10:00
J. Nick Koston
3df837cc82 Ensure login token is only sent if aes state is ESTABLISHED (#702) 2024-01-24 09:43:42 -10:00
Teemu R
aecf0ecd8a Do not crash on missing geolocation (#701)
If 'has_set_location_info' is false, the geolocation is missing.
2024-01-24 12:21:37 +00:00
J. Nick Koston
bab40d43e6 Renew the handshake session 20 minutes before we think it will expire (#697)
* Renew the KLAP handshake session 20 minutes before we think it will expire

Currently we assumed the clocks were perfectly aligned and the handshake
session lasted 20 hours.  We now add a 20 minute buffer

* use timeout cookie when available
2024-01-24 10:11:27 +01:00
J. Nick Koston
24c645746e Refactor aestransport to use a state enum (#691) 2024-01-23 22:50:25 -10:00
Steven B
eb217a748c Fix test_klapprotocol test duration (#698) 2024-01-23 22:20:44 -10:00
Teemu R
8b566757c3 Add new cli command 'command' to execute arbitrary commands (#692)
* Add new cli command 'command' to execute arbitrary commands

This deprecates 'raw-command', which requires positional argument for module,
in favor of new 'command' that accepts '--module' option for IOT devices.

* Pull block list to the module level
2024-01-24 09:10:55 +01:00
J. Nick Koston
5907dc763a Add fixtures for L510E (#693)
* Add fixtures for L510E

* mac
2024-01-24 06:59:39 +00:00
Teemu R
52c3fb4d52 Add 1003 (TRANSPORT_UNKNOWN_CREDENTIALS_ERROR) (#667) 2024-01-24 00:12:01 +01:00
Steven B
1788c50146 Update transport close/reset behaviour (#689)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-01-23 12:15:18 -10:00
Teemu R
e576fcdb46 Allow raw-command and wifi without update (#688)
* Allow raw-command and wifi without update

* Call update always but on wifi&raw-command

* Add tests

* Skip update also if device_family was defined, as device factory performs an update
2024-01-23 22:58:57 +01:00
Steven B
f045696ebe Fix P100 error getting conn closed when trying default login after login failure (#690) 2024-01-23 11:51:07 -10:00
Steven B
e233e377ad Generate AES KeyPair lazily (#687)
* Generate AES KeyPair lazily

* Fix coverage

* Update post-review

* Fix pragma

* Make json dumps consistent between python and orjson

* Add comment

* Add comments re json parameter in HttpClient
2024-01-23 15:29:27 +00:00
Steven B
718983c401 Try default tapo credentials for klap and aes (#685)
* Try default tapo credentials for klap and aes

* Add tests
2024-01-23 14:44:32 +00:00
Teemu R
c8ac3a29c7 Add reboot and factory_reset to tapodevice (#686)
* Add reboot and factory_reset to tapodevice

* Add test for reboot command

* Fix mocking as different protocols use different methods for comms..
2024-01-23 14:26:47 +01:00
Teemu R
cfbdf7c64a Show discovery data for state with verbose (#678)
* Show discovery data for state with verbose

* Remove duplicate discovery printout on discovery, add a newline for readability
2024-01-23 13:24:17 +01:00
J. Nick Koston
d5fdf05ed2 Add P100 test fixture (#683) 2024-01-23 10:12:24 +00:00
J. Nick Koston
abd3ee0768 Add P135 fixture (#673)
* Add P135 fixture

This device is a dimmer but we currently treat it as a on/off

* add to conftest
2024-01-23 08:31:19 +01:00
J. Nick Koston
65c47a9373 Update fixtures from test devices (#679)
* Update fixtures from test devices

* move l920 to another pr
2024-01-23 08:12:54 +01:00
J. Nick Koston
37f522c763 Add L530E(US) fixture (#674) 2024-01-23 06:24:08 +01:00
Steven B
ee487ad837 Sleep between discovery packets (#656)
* Sleep between discovery packets

* Add tests
2024-01-22 18:25:23 +01:00
Steven B
6b0a72d5a7 Add protocol and transport documentation (#663)
* Add protocol and transport documentation

* Update post review
2024-01-22 17:45:19 +01:00
Steven B
14acc8550e Rename base TPLinkProtocol to BaseProtocol (#669) 2024-01-22 16:28:30 +01:00
Teemu R
df59791829 Add l900-5 1.1.0 fixture (#664)
* Adds new localSmart module
* Changed from AES to klap
* Doesn't reboot itself when receiving a RST for the cloud connectivity requests
2024-01-21 01:41:13 +01: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
49cfef087c Make close behaviour consistent across new protocols and transports (#660) 2024-01-20 13:35:05 +01:00
Steven B
e94cd118a4 Add fixtures with new MAC mask (#661) 2024-01-20 13:22:54 +01:00
J. Nick Koston
8523800b23 Fix minor typos in docstrings (#659) 2024-01-20 02:40:21 +01:00
J. Nick Koston
d62b5a55cc Improve and document close behavior (#654)
* Close connection on smartprotocol timeout

* tweaks
2024-01-19 21:30:01 +01:00
Steven B
38159140fb Fix httpclient exceptions on read and improve error info (#655) 2024-01-19 21:06:50 +01:00
Steven B
bedf05ce3b Remove time logging in debug message (#645) 2024-01-18 08:32:58 -10:00
Steven B
c3329155c8 Raise SmartDeviceException on invalid config dicts (#640)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-01-18 07:51:50 -10:00
Steven B
642e9a1f5b Migrate http client to use aiohttp instead of httpx (#643) 2024-01-18 07:32:26 -10: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
J. Nick Koston
eadf1203fc Add fixture for L920 (#638) 2024-01-14 23:49:31 +01:00
J. Nick Koston
aed67dad16 Fix connection indeterminate state on cancellation (#636)
* Fix connection indeterminate state on cancellation

If the task the query is running in it cancelled, we do
know the state of the connection so we must close. Previously
we would not close on BaseException which could result
in reading the previous response if the previous query was
cancelled after the request had been sent

* add test for cancellation
2024-01-13 18:37:24 +01:00
Steven B
fbce755544 Raise TimeoutException on discover_single timeout (#632) 2024-01-11 16:13:44 +01:00
Steven B
5b8280a8d9 Return alias as None for new discovery devices before update (#627)
* Trim the length of the unavailable device alias

* Update to use short mac as auth required alias

* Update to return alias as none
2024-01-11 16:12:02 +01:00
Steven B
fd2170c82c Update config to_dict to exclude credentials if the hash is empty string (#626)
* Update config to_dict to exclude credentials if the hash is empty string

* Add test
2024-01-10 20:47:30 +01:00
Steven B
d5a6fd8e73 Improve test coverage (#625) 2024-01-10 20:37:43 +01:00
Steven B
3e0cd07b7c Update docs for newer devices and DeviceConfig (#614)
* Update docs for newer devices and DeviceConfig

* Tweak docs post review

* Move sentence to newline

* Update post review

* Update following review
2024-01-10 20:13:14 +01:00
Steven B
897db674c2 Add L900-10 fixture and it's additional component requests (#629) 2024-01-10 19:40:36 +01:00
J. Nick Koston
460054ced7 Avoid recreating struct each request in legacy protocol (#628) 2024-01-09 13:51:04 -10:00
Nathan Wreggit
cfe694e5de Get child emeters with CLI (#623)
* Get child emeters with CLI

* Avoid extra IO when not que querying the child emeter
2024-01-05 02:25:24 +01:00
Teemu R
2d8a8d9511 Add update-credentials command (#620)
* Add change credentials command

* Rename command and add prompts for credential update
2024-01-05 02:25:15 +01:00
J. Nick Koston
554fe0a96e Avoid linear search for emeter realtime and emeter_today (#622)
* Avoid linear search for emeter realtime and emeter_today

Most of the time the data we want is at the end of the
list so we now search backwards to avoid having to
scale all the data and throw most of it away

* more tweaks

* coverage

* coverage

* preen

* coverage

* branch cover
2024-01-05 02:01:00 +01:00