Commit Graph

463 Commits

Author SHA1 Message Date
Teemu R
f1b28e79b9
Add KL130 fixture, initial lightstrip tests (#214) 2021-09-24 22:26:21 +02:00
Teemu R
acb221b1e0
Cleanup discovery & add tests (#212)
* Cleanup discovery & add tests

* discovered_devices_raw is not anymore available, as that can be accessed directly from the device objects
* test most of the discovery code paths
* some minor cleanups to test handling
* update discovery docs

* Move category check to be after the definitions

* skip a couple of tests requiring asyncmock not available on py37

* Remove return_raw usage from cli.discover
2021-09-24 17:18:11 +02:00
Teemu R
bdb07a749c
Release 0.4.0.dev4 (#210)
* Release 0.4.0.dev4

The most important enhancements in this release are:
* Support for emeter on strip sockets
* Fix discovery and update() on some devices that do not support multi-module queries (e.g., HS200)
* Improved support for bulbs

[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.4.0.dev3...0.4.0.dev4)

**Implemented enhancements:**

- HS300 Children plugs have emeter [\#64](https://github.com/python-kasa/python-kasa/issues/64)
- Improve emeterstatus API, move into own module [\#205](https://github.com/python-kasa/python-kasa/pull/205) ([rytilahti](https://github.com/rytilahti))
- Avoid temp array during encrypt and decrypt [\#204](https://github.com/python-kasa/python-kasa/pull/204) ([bdraco](https://github.com/bdraco))
- Add emeter support for strip sockets [\#203](https://github.com/python-kasa/python-kasa/pull/203) ([bdraco](https://github.com/bdraco))
- Add own device type for smartstrip children [\#201](https://github.com/python-kasa/python-kasa/pull/201) ([rytilahti](https://github.com/rytilahti))
- bulb: allow set\_hsv without v, add fallback ct range [\#200](https://github.com/python-kasa/python-kasa/pull/200) ([rytilahti](https://github.com/rytilahti))
- Improve bulb support \(alias, time settings\) [\#198](https://github.com/python-kasa/python-kasa/pull/198) ([rytilahti](https://github.com/rytilahti))
- Improve testing harness to allow tests on real devices [\#197](https://github.com/python-kasa/python-kasa/pull/197) ([rytilahti](https://github.com/rytilahti))
- cli: add human-friendly printout when calling temperature on non-supported devices [\#196](https://github.com/python-kasa/python-kasa/pull/196) ([JaydenRA](https://github.com/JaydenRA))

**Fixed bugs:**

- KL430: Throw error for Device specific information [\#189](https://github.com/python-kasa/python-kasa/issues/189)
- dump\_devinfo: handle latitude/longitude keys properly [\#175](https://github.com/python-kasa/python-kasa/pull/175) ([rytilahti](https://github.com/rytilahti))

**Closed issues:**

- Feature Request - Toggle Command [\#188](https://github.com/python-kasa/python-kasa/issues/188)
- Is It Compatible With HS105? [\#186](https://github.com/python-kasa/python-kasa/issues/186)
- Cannot use some functions with KP303 [\#181](https://github.com/python-kasa/python-kasa/issues/181)
- Help needed - awaiting game  [\#179](https://github.com/python-kasa/python-kasa/issues/179)
- Version inconsistency between CLI and pip [\#177](https://github.com/python-kasa/python-kasa/issues/177)
- Release 0.4.0.dev3? [\#169](https://github.com/python-kasa/python-kasa/issues/169)
- Discover does not support specifying network interface [\#167](https://github.com/python-kasa/python-kasa/issues/167)
- Can't command or query HS200 v5 switch [\#161](https://github.com/python-kasa/python-kasa/issues/161)

**Merged pull requests:**

- More CI fixes [\#208](https://github.com/python-kasa/python-kasa/pull/208) ([rytilahti](https://github.com/rytilahti))
- Fix CI dep installation [\#207](https://github.com/python-kasa/python-kasa/pull/207) ([rytilahti](https://github.com/rytilahti))
- Use github actions instead of azure pipelines [\#206](https://github.com/python-kasa/python-kasa/pull/206) ([rytilahti](https://github.com/rytilahti))
- Add KP115 fixture [\#202](https://github.com/python-kasa/python-kasa/pull/202) ([rytilahti](https://github.com/rytilahti))
- Perform initial update only using the sysinfo query [\#199](https://github.com/python-kasa/python-kasa/pull/199) ([rytilahti](https://github.com/rytilahti))
- Add real kasa KL430\(UN\) device dump [\#192](https://github.com/python-kasa/python-kasa/pull/192) ([iprodanovbg](https://github.com/iprodanovbg))
- Use less strict matcher for kl430 color temperature [\#190](https://github.com/python-kasa/python-kasa/pull/190) ([rytilahti](https://github.com/rytilahti))
- Add EP10\(US\) 1.0 1.0.2 fixture [\#174](https://github.com/python-kasa/python-kasa/pull/174) ([nbrew](https://github.com/nbrew))
- Add a note about using the discovery target parameter [\#168](https://github.com/python-kasa/python-kasa/pull/168) ([leandroreox](https://github.com/leandroreox))

* replace pypy3 with pypy-3.7 as we do not support python3.6 anyway

* skip pypy-3.7 on windows to avoid flaky ci
2021-09-24 01:44:22 +02:00
J. Nick Koston
94e5a90ac4
Add emeter support for strip sockets (#203)
* Add support for plugs with emeters.

* Tweaks for emeter

* black

* tweaks

* tweaks

* more tweaks

* dry

* flake8

* flake8

* legacy typing

* Update kasa/smartstrip.py

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

* reduce

* remove useless delegation

* tweaks

* tweaks

* dry

* tweak

* tweak

* tweak

* tweak

* update tests

* wrap

* preen

* prune

* prune

* prune

* guard

* adjust

* robust

* prune

* prune

* reduce dict lookups by 1

* Update kasa/smartstrip.py

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

* delete utils

* isort

Co-authored-by: Brendan Burns <brendan.d.burns@gmail.com>
Co-authored-by: Teemu R. <tpr@iki.fi>
2021-09-24 00:24:44 +02:00
Teemu R
d7202883e9
More CI fixes (#208)
* Remove bandit from CI, update poetry.lock&pre-commit-config.yaml

* We don't support python 3.6

* poetry install also on tests flow

* remove pytest-azurepipelines
2021-09-23 19:09:19 +02:00
Teemu R
202d107d39
Fix CI dep installation (#207) 2021-09-23 18:29:45 +02:00
Teemu R
41bed35e01
Use github actions instead of azure pipelines (#206)
* Use github actions instead of azure pipelines

* add codecov badge
2021-09-23 18:25:41 +02:00
J. Nick Koston
b3c8f9769c
Avoid temp array during encrypt and decrypt (#204)
* Avoid temp array during encrypt

* black

* Update kasa/protocol.py

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

* Update kasa/protocol.py

* update decrypt as well

Co-authored-by: Teemu R. <tpr@iki.fi>
2021-09-23 18:11:16 +02:00
Teemu R
36c412a9c2
Improve emeterstatus API, move into own module (#205)
Adds the following properties to EmeterStatus for saner API:
* voltage (in V)
* power (in W)
* current (in A)
* total (in kWh)
2021-09-23 17:58:19 +02:00
Teemu R
47a1405bd2
Add KP115 fixture (#202) 2021-09-21 19:20:59 +02:00
Teemu R
151976bb04
Add own device type for smartstrip children (#201) 2021-09-21 13:25:14 +02:00
Teemu R
2c83d8ee6d
bulb: allow set_hsv without v, add fallback ct range (#200)
* bulb: allow set_hsv without v, add fallback ct range

* add ColorTempRange and HSV named tuples
* add a fallback color temp range if unknown, log a warning
* set_hsv: the value is now optional

* Fix tests, change fallback range to 2700-5000
2021-09-21 13:23:56 +02:00
Leandro Reox
7565d03c8e
Add a note about using the discovery target parameter (#168)
* Update discover.py

Updated discovery documentation for multiple interfaces explanation

* revise

Co-authored-by: Teemu R <tpr@iki.fi>
2021-09-20 00:01:06 +02:00
Teemu R
016d030245
Improve bulb support (alias, time settings) (#198)
* Fix set_alias and time related functions for bulbs

* Fix tests for smartlife.iot.common.timesetting and smartlife.iot.common.system
2021-09-19 23:53:17 +02:00
Teemu R
1803a83ae6
Improve testing harness to allow tests on real devices (#197)
* test_cli: provide return values to patched objects to avoid warning about non-awaited calls

* test_cli: restore alias after testing

* smartstrip: remove internal update() calls for turn_{on,off}, set_led

* Make sure power is always a float

* Fix discovery tests

* Make tests runnable on real devices

* Add a note about running tests on a real device

* test_strip: run update against the parent device
2021-09-19 23:45:48 +02:00
Teemu R
b088596205
Perform initial update only using the sysinfo query (#199)
Some devices are known to fail when trying to query non-supported modules like emeter information.
This commit makes the initial update() only request the sysinfo, followed up by a second query
if emeter is supported by the device.
2021-09-19 23:43:17 +02:00
JaydenRA
f8e7258b93
cli: add human-friendly printout when calling temperature on non-supported devices (#196)
* Bug Fix

Temperature is not supported on plugs

* Efficiency on support errors

* Update kasa/cli.py

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

Co-authored-by: Teemu R. <tpr@iki.fi>
2021-09-04 02:18:21 +02:00
Ivan Prodanov
7c9d21af7a
Add real kasa KL430(UN) device dump (#192)
* Add real kasa KL430(UN) device dump

* Adjust hue&sat max values

* light strips, as bulbs, have only power for emeter

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2021-08-16 20:16:29 +02:00
Teemu R
4e8a3185fb
Use less strict matcher for kl430 color temperature (#190) 2021-08-16 16:49:28 +02:00
Nathan Hyde
6184c0c72e
Add EP10(US) 1.0 1.0.2 fixture (#174)
* Add EP10(US) 1.0 1.0.2 fixture

* Add EP10 fixture to conftest PLUGS list.

* Add EP10 to the list of supported plugs in README

* Revert "Add EP10 to the list of supported plugs in README"

This reverts commit e8bf6551c3.
2021-06-24 19:43:54 +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
0aa20f6cf9
Prepare 0.4.0.dev3 (#172)
* Prepare 0.4.0.dev3

Most notable changes:

* Devices initialized by discovery are pre-initialized using the discovery response data, so no need for update() directly after discovery
* Only the basic information is requested during discovery, as some HS110 and HS220 devices do not respond to multi-module queries
* Fix mac address parsing for KL430
* Add support for KL125 color temperature ranges
* Documentation updates!

* add types-click for mypy hook

* use generator expression for sum
2021-06-16 18:16:45 +03:00
Appleguru
8a3ebbff6d
Add HS220 hw 2.0 fixture (#107)
* Add HS220 hw 2.0 fixture

* Update HS220 v2 profile from dump-discover

* fix linting

Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
2021-05-12 18:04:17 +02:00
Teemu R
c7a47ea1bf
Simplify mac address handling (#162) 2021-05-12 16:07:53 +03:00
Brian Davis
28a902c485
Added KL125 and HS200 fixture dumps and updated tests to run on new format (#160)
* Added new fixtures

* Refactored bulb categories and check for emeter on run

* linting changes
2021-05-11 17:47:52 +02: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
mdarnol
2fe1b209d0
Add KL125 bulb definition (#143)
Co-authored-by: Mark Arnold <marnold@nvidia.com>
2021-02-27 15:09:33 +01:00
Flaviof
848c38117b
README.md: Add link to MQTT interface for python-kasa (#140)
Add reference to https://github.com/flavio-fernandes/mqtt2kasa for users
who may be interested in using MQTT to control/monitor devices managed
by python-kasa
2021-02-18 23:24:53 +01:00
Flaviof
87730e6c4e
Fix documentation on Smart strips (#136)
Trivial Fix

Fix documentation and the corresponding command when
turning on/off example.
2021-02-15 17:59:17 +01:00
Teemu R
8a5c5507c8
add tapo link, fix tplink-smarthome-simulator link (#133)
* add link to tapo p100 project
* fix tplink-smarthome-simulator link
2021-02-07 22:25:42 +01:00
dlee1j1
d4a361dd3e
Leverage data from UDP discovery to initialize device structure (#132)
* avoid talking to devices after UDP discovery

* formatting fix

* more formatting

* more formatting changes

* undo gitignore changes

* fixing git ignore for black

Co-authored-by: dlee1j1 <dlee1j@yahoo.comm>
2021-02-06 16:14:36 +01:00
Teemu R
98b40b5072
Improve cli documentation for bulbs and power strips (#123) 2020-12-09 11:13:14 +02:00
Teemu R
a926ff5980
Release 0.4.0.dev2 (#118) 2020-11-21 22:52:13 +01:00
Teemu R
56eb2cdcb5
Simplify device class detection, fix hardcoded timeout for discovery (#112) 2020-11-08 14:32:27 +01:00
BuongiornoTexas
70061cbe67
Update cli.py to addresss crash on year/month calls and improve output formatting (#103)
* Update cli.py

Fix crash when kasa cli is called with --month or --year arguments.

* Update cli.py

* Fix crash on emeter monthly, yearly cli calls

* Formatting fix.
2020-10-03 20:32:38 +02:00
Teemu R
c59b748a06
Pin dependencies on major versions, add poetry.lock (#94)
* Pin dependencies on major versions, add poetry.lock

* Fix linting
2020-07-29 19:28:00 +02:00
Dmitrii Eliuseev
1cd1e84f78
'Interface' parameter added to discovery process (#79)
* 'Interface' parameter added to discovery process

Some systems (for example dd-wrt) requires specifying the network interface name, otherwise the broadcast does not work

* 'Interface' variable type and check fixed

* Formatting fixed

* Update kasa/discover.py

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

Co-authored-by: Teemu R. <tpr@iki.fi>
2020-07-28 23:20:58 +02:00
Teemu R
c67bda8230
Release 0.4.0.dev1 (#93)
* Release 0.4.0.pre1

* update RELEASING.md

* Fix release naming from .pre to .dev
2020-07-28 16:55:56 +02:00
Teemu R
6844166c0d
add a small example script to show library usage (#90)
* add a small example script to show library usage

* asyncio.run++
2020-07-20 16:42:37 +02:00
Teemu R
d30d00a3ff
Add support for lightstrips (KL430) (#74)
* Preliminary support for light strips

* Add color temperature range and cleanup, thanks to @darkoppressor

* Use lightstrip instead of {led,light}strip consistently everywhere
* The cli flag is now --lightstrip

* add apidocs

* Add fixture file for KL430

Signed-off-by: Kevin Wells <darkoppressor@gmail.com>

* Add discovery support, expose effect and length of the strip

* use set_light_state instead of transition_light_state

* Add tests for lightstrip

* add doctests

* Add KL430 to supported devices in README

Co-authored-by: Kevin Wells <darkoppressor@gmail.com>
2020-07-19 22:32:17 +02:00
Teemu R
0edbb4301f
add .readthedocs.yml required for poetry doc builds (#89)
* add .readthedocs.yml required for poetry builds

* require python 3.7 for builds

* Add documentation badge, fix the docs link
2020-07-12 23:28:20 +02: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
Teemu R
fccb897a5b
Improve installation instructions (#86)
* Improve installation instructions

* Add simple instructions how to install the package
* Move the list of supported devices to the end of the file

Fixes #60 (hopefully)

* Remove 'see below for devenv instructions'
2020-07-12 22:46:21 +02:00
Teemu R
96c15362c3
cli: Fix incorrect use of asyncio.run for temperature command (#85) 2020-07-06 21:46:40 +02:00
Teemu R
4d722e25c1
Add --transition to bulb-specific cli commands, fix turn_{on,off} signatures (#81) 2020-07-06 16:10:28 +02:00
Teemu R
44e2998705
Improve bulb API, force turn on for all light changes as offline changes are not supported (#76)
* Add ignore_default to lights to allow setting to specific light state, force bulb on when changing the settings, allow defining brightness for set_color_temp, add a couple of new API methods

* Fix and simplify transition_light_state to make tests pass
2020-07-06 16:09:30 +02:00
Teemu R
f9a987ca18
Simplify API documentation by using doctests (#73)
* Add doctests to SmartBulb

* Add SmartDevice doctests, cleanup README.md

* add doctests for smartplug and smartstrip

* add discover doctests

* Fix bulb mock

* add smartdimmer doctests

* add sphinx-generated docs, cleanup readme a bit

* remove sphinx-click as it does not work with asyncclick

* in preparation for rtd hooking, move doc deps to be separate from dev deps

* pytestmark needs to be applied separately for each and every file, this fixes the tests

* use pathlib for resolving relative paths

* Skip discovery doctest on python3.7

The code is just fine, but some reason the mocking behaves differently between 3.7 and 3.8.
The latter seems to accept a discrete object for asyncio.run where the former expects a coroutine..
2020-06-30 02:29:52 +02:00
Teemu R
99e0c4a418
Bulbs: allow specifying transition for state changes (#70)
All state changing functions now allow defining transition time in milliseconds
2020-06-14 20:21:55 +02:00
Connor Proctor
dd073fa8c8
Add transition support for SmartDimmer (#69)
* Adds a transition param to set_brightness(), turn_on(), and turn_off() that specifies the duration in milliseconds that the dimmer switch will take to transition to the new state.
* Fixes bug where set_brightness(0) was allowed even though the dimmer does not support it. Now brightness values of 0 are coerced to 1 to be consistent with bulbs (which do support brightness values of 0).
2020-06-14 18:09:28 +02:00