Commit Graph

355 Commits

Author SHA1 Message Date
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
Julian Davis
334ba1713a
Added .gitattributes file to retain LF only EOL markers when checking out on Windows (#399) 2023-02-18 17:20:06 +01:00
Teemu R
6e7a588d40
Add brightness to lightstrip's set_effect (#415)
* Add brightness parameter to lightstrip's set_effect

* Use None as default as effects have different default brightnesses
2023-01-21 00:25:59 +01:00
dependabot[bot]
bfafbf9512
Bump certifi from 2021.10.8 to 2022.12.7 (#409)
Bumps [certifi](https://github.com/certifi/python-certifi) from 2021.10.8 to 2022.12.7.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](https://github.com/certifi/python-certifi/compare/2021.10.08...2022.12.07)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-11 19:28:28 +01:00
Teemu R
362c60d7b1
Add FUNDING.yml (#402) 2022-11-15 19:12:38 +01:00
Teemu R
327efb6c65
Update pre-commit hooks (#401)
* Update pre-commit hooks

* Fix implicit optionals
2022-11-15 19:05:08 +01:00
Teemu R
ad5b5c2230
Update pre-commit url for flake8 (#400) 2022-11-15 18:26:23 +01:00
Julian Davis
866c8d6db5
Fix pytest warnings about asyncio (#397)
Turn on ayncio auto mode for pytest and remove the global async marking flag
2022-11-13 23:34:47 +01:00
Teemu R
9cb2a56405
Add a note that transition is not supported by all devices (#398) 2022-11-11 21:06:54 +01:00
Aric Forrest
ec06331737
Adding cli command to delete a schedule rule (#391)
* adding cli option to delete rule

* resolving black linting issue

* simplifying command name

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

* updating rule filter

Co-authored-by: Teemu R. <tpr@iki.fi>
2022-11-03 02:11:24 +01:00
Teemu R
ef98c2aed9
Implement changing the bulb turn-on behavior (#381)
* Implement changing the bulb turn-on behavior

* Improve docstrings a bit

* Improve docs and expose TurnOnBehavior(s)

* fix typing
2022-10-27 17:40:54 +02:00
Julian Davis
1ac6c66277
Fix type hinting issue with call to click.Choice (#387)
* Fix type hinting issue with call to click.Choice which takes a Sequence not dictionary. Convert TYPE_TO_CLASS keys to a list to pass in.

* Update kasa/cli.py

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

Co-authored-by: Jules Davis <jules@focalpointvr.com>
Co-authored-by: Teemu R. <tpr@iki.fi>
2022-10-27 17:40:24 +02:00
Teemu R
f32f7f3925
Add support for bulb presets (#379)
* Add support for bulb presets

* Update docs
2022-10-23 00:15:47 +02:00
HankB
b386485ab0
Update smartstrip.rst (#382)
```text
hbarta@pilog3b:~$ kasa --type strip --host 192.168.20.215 on
Turning on TP-LINK_Smart Plug_83A6
hbarta@pilog3b:~$ kasa --strip --host 192.168.20.215 on
Usage: kasa [OPTIONS] COMMAND [ARGS]...
Try 'kasa --help' for help.

Error: No such option: --strip (Possible options: --host, --type)
hbarta@pilog3b:~$
```
2022-10-19 01:16:11 +02:00
HankB
e1a30f92e4
fix more outdated CLI examples, remove EP40 from bulb list (#383)
* Fix more outdated cli examples

* remove EP40 (smart strip) from bulb list
2022-10-18 23:37:54 +02:00
Teemu R
2eecf39bae
Add ToCs for doc pages (#380) 2022-10-18 19:08:10 +02:00
Teemu R
f493fa1dca
Clarify information about supported devices (#377)
* Clarify information about supported devices

* Use single backticks
2022-10-17 18:16:40 +02:00
Teemu R
cece84352a
Manually pass the codecov token in CI (#378) 2022-10-17 18:08:26 +02:00
Teemu R
13052ac7a1
Fix year emeter for cli by using kwarg for year parameter (#372)
* Fix year emeter for cli by using kwarg for year parameter

* Improve tests

* Skip test_emeter on python3.7
2022-10-03 20:28:05 +02:00
Felix Yan
7aebef56ca
Correct typos in smartdevice.py (#358) 2022-07-17 19:19:09 +02:00
gritstub
57fac9a156
Add fixtures for KS200M (#356) 2022-06-28 18:53:23 +02:00
gritstub
d7295bdf6d
Add fixtures for ES20M (#353) (#354)
Co-authored-by: Teemu R <tpr@iki.fi>
2022-06-28 13:06:34 +02:00
gritstub
4c55289255
Add fixtures for KS230 (#355) 2022-06-28 12:56:36 +02:00
Teemu R
8c93c44440
Update README to add missing models and fix a link (#351) 2022-06-27 17:26:45 +02:00
James Alseth
91ba1d5ac6
Add KP125 test fixture and support note. (#350)
* Add KP125 test fixture and support note.

Signed-off-by: James Alseth <james@jalseth.me>

* mark KP125 having an emeter

Co-authored-by: Teemu R <tpr@iki.fi>
2022-06-27 03:39:57 +02:00
J. Nick Koston
8e6cfd003e
Add fixtures for KP100 (#343)
* Add fixtures for KP100

* readme
2022-05-11 16:02:17 +02:00
Teemu R
604520dcaf
Add codeql checks (#338) 2022-04-25 14:45:53 +02:00
Teemu R
51fb908d8b
Prepare 0.5.0 (#342)
* Prepare 0.5.0

* Add note about how to include release summary to changelog
2022-04-25 00:13:24 +02:00
J. Nick Koston
d908a5ab2a
Avoid retrying open_connection on unrecoverable errors (#340)
* Avoid retrying open_connection on unrecoverable errors

- We can retry so hard that we block the event loop

Fixes
```
2022-04-16 22:18:51 WARNING (MainThread) [asyncio] Executing <Task finished name=Task-3576 coro=<open_connection() done, defined at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/streams.py:25> exception=ConnectionRefusedError(61, "Connect call failed (192.168.107.200, 9999)") created at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:460> took 1.001 seconds
```

* comment
2022-04-24 19:38:42 +02:00
J. Nick Koston
d2581bf077
Add fixtures for kl420 (#339)
* Add fixtures for kl420

* readme
2022-04-14 02:51:15 +02:00
Teemu R
631762b50c
Drop deprecated, type-specific options in favor of --type (#336)
* Drop deprecated, type-specific options in favor of --type

* Fix tests
2022-04-06 03:39:50 +02:00
Teemu R
6e988bd9a9
Avoid discovery on --help (#335) 2022-04-06 02:25:47 +02:00
Teemu R
a39cef9a8c
Export modules & make sphinx happy (#334) 2022-04-06 01:41:08 +02:00
Teemu R
d848117384
Various documentation updates (#333)
* Add a note about socket sharing

* Show inherited members for apidocs

* Remove outdated note of emeters not being supported on smartstrips

* Describe emeter and usage modules, add note about NTP for time sync

* Describe lib design and modules

* Bump sphinx version, ignore d001 (line-length) for doc8

* demote energy & usage to 3rd level, promote api for 2nd
2022-04-06 01:13:27 +02:00
Teemu Rytilahti
68038c93df Bump version to 0.5.0.dev0 2022-04-05 19:27:46 +02:00
Teemu Rytilahti
2a0919efd5 Fix linting 2022-04-05 19:27:46 +02:00
J. Nick Koston
1e4df7ec1b Fix modularize with strips (#326)
* Fix test_deprecated_type stalling

* Fix strips with modularize

* Fix test_deprecated_type stalling (#325)
2022-04-05 19:27:46 +02:00
Teemu Rytilahti
f0d66e4195 move get_time{zone} out from smartdevice + some minor cleanups 2022-04-05 19:27:46 +02:00
Teemu Rytilahti
c8ad99abcb Use device time for on_since for smartstripplugs 2022-04-05 19:27:46 +02:00
Teemu Rytilahti
bb013e75da Raise an exception when trying to access data prior updating 2022-04-05 19:27:46 +02:00
Teemu R
3a7836cd33 Do not request unsupported modules after the initial update (#298)
* Do not request unsupported modules after the initial update

* debugify logging
2022-04-05 19:27:46 +02:00
Teemu R
8c7b1b4a68 Implement motion & ambient light sensor modules for dimmers (#278) 2022-04-05 19:27:46 +02:00
Teemu R
e3588047fc Improve usage module, consolidate API with emeter (#249)
* Consolidate API for both emeter&usage modules
* Add new cli command 'usage' to query usage
2022-04-05 19:27:46 +02:00
Teemu R
3926f3224f Add module support & query their information during update cycle (#243)
* Add module support & modularize existing query

This creates a base to expose more features on the supported devices.
At the moment, the most visible change is that each update cycle gets information from all available modules:
* Basic system info
* Cloud (new)
* Countdown (new)
* Antitheft (new)
* Schedule (new)
* Time (existing, implements the time/timezone handling)
* Emeter (existing, partially separated from smartdevice)

* Fix imports

* Fix linting

* Use device host instead of alias in module repr

* Add property to list available modules, print them in cli state report

* usage: fix the get_realtime query

* separate usage from schedule to avoid multi-inheritance

* Fix module querying

* Add is_supported property to modules
2022-04-05 19:27:46 +02:00
Teemu R
7b9e3aae8a
Release 0.4.3 (#332)
This release fixes an issue where the bulb state on led strips was not restored properly when turned back on.

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

**Fixed bugs:**

- Divide by zero when HS300 powerstrip is discovered [\#292](https://github.com/python-kasa/python-kasa/issues/292)
- Ensure bulb state is restored when turning back on [\#330](https://github.com/python-kasa/python-kasa/pull/330) (@bdraco)

**Closed issues:**

- KL420L5 controls [\#327](https://github.com/python-kasa/python-kasa/issues/327)

**Merged pull requests:**

- Update pre-commit hooks to fix black in CI [\#331](https://github.com/python-kasa/python-kasa/pull/331) (@rytilahti)
- Fix test\_deprecated\_type stalling [\#325](https://github.com/python-kasa/python-kasa/pull/325) (@bdraco)
2022-04-05 19:02:00 +02:00
J. Nick Koston
766819a2a4
Ensure bulb state is restored when turning back on (#330)
* Ensure state is restored when turning back on

Fixes https://github.com/home-assistant/core/issues/69039

* Update kasa/tests/test_bulb.py

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

Co-authored-by: Teemu R. <tpr@iki.fi>
2022-04-05 18:51:36 +02:00
Teemu R
a744af46ab
Update pre-commit deps to fix CI (#331) 2022-04-05 17:48:24 +02:00
J. Nick Koston
2b05751aa7
Fix test_deprecated_type stalling (#325) 2022-03-24 23:59:53 +01:00
Teemu R
6f5a60ad43
Release 0.4.2 (#321)
This is the last release prior restructuring the code to enable easier extendability by moving towards more modular architecture.
The most prominent change in this release is the support for effects on light strips.

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

**Implemented enhancements:**

- Allow environment variables for discovery target, device type and debug [\#313](https://github.com/python-kasa/python-kasa/pull/313) (@rytilahti)
- Add 'internal\_state' to return the results from the last update query [\#306](https://github.com/python-kasa/python-kasa/pull/306) (@rytilahti)
- Drop microsecond precision for on\_since [\#296](https://github.com/python-kasa/python-kasa/pull/296) (@rytilahti)
- Add effect support for light strips [\#293](https://github.com/python-kasa/python-kasa/pull/293) (@bdraco)

**Fixed bugs:**

- TypeError: \_\_init\_\_\(\) got an unexpected keyword argument 'package\_name' [\#311](https://github.com/python-kasa/python-kasa/issues/311)
- RuntimeError: Event loop is closed on WSL [\#294](https://github.com/python-kasa/python-kasa/issues/294)
- Don't crash on devices not reporting features [\#317](https://github.com/python-kasa/python-kasa/pull/317) (@rytilahti)

**Closed issues:**

- SmartDeviceException: Communication error on system:set\_relay\_state [\#309](https://github.com/python-kasa/python-kasa/issues/309)
- Add Support: ES20M and KS200M motion/light switches [\#308](https://github.com/python-kasa/python-kasa/issues/308)
- New problem with installing on Ubuntu 20.04.3 LTS [\#305](https://github.com/python-kasa/python-kasa/issues/305)
- KeyError: 'emeter' when discovering [\#302](https://github.com/python-kasa/python-kasa/issues/302)
- RuntimeError: Event loop is closed  [\#291](https://github.com/python-kasa/python-kasa/issues/291)
- provisioning format [\#290](https://github.com/python-kasa/python-kasa/issues/290)
- Fix CI publishing on pypi [\#222](https://github.com/python-kasa/python-kasa/issues/222)
- LED strips effects are not supported \(was LEDs is not turning on after switching on\) [\#191](https://github.com/python-kasa/python-kasa/issues/191)

**Merged pull requests:**

- Add pyupgrade to CI runs [\#314](https://github.com/python-kasa/python-kasa/pull/314) (@rytilahti)
- Depend on asyncclick \>= 8 [\#312](https://github.com/python-kasa/python-kasa/pull/312) (@rytilahti)
- Guard emeter accesses to avoid keyerrors [\#304](https://github.com/python-kasa/python-kasa/pull/304) (@rytilahti)
- cli: cleanup discover, fetch update prior device access [\#303](https://github.com/python-kasa/python-kasa/pull/303) (@rytilahti)
- Fix unsafe \_\_del\_\_ in TPLinkSmartHomeProtocol [\#300](https://github.com/python-kasa/python-kasa/pull/300) (@bdraco)
- Improve typing for protocol class [\#289](https://github.com/python-kasa/python-kasa/pull/289) (@rytilahti)
- Added a fixture file for KS220M [\#273](https://github.com/python-kasa/python-kasa/pull/273) (@mrbetta)
2022-03-21 22:34:44 +01:00
J. Nick Koston
58f6517445
Add effect support for light strips (#293)
* Add effect support for KL430

* KL400 supports effects

* Add KL400 fixture

* Comments from review

* actually commit the remove
2022-03-21 22:10:12 +01:00