Commit Graph

604 Commits

Author SHA1 Message Date
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
Teemu R
9dc0cbaece
Add retries to protocol queries (#65)
* Add retries to query(), defaults to 3 + add tests

* Catch also json decoding errors for retries

* add missing exceptions file, fix old protocol tests
2020-05-27 20:02:09 +03:00
Teemu R
644a10a0d1
General cleanups all around (janitoring) (#63)
* Move tests to device-type specific test files to make improvements more approachable

* protocol: remove the port parameter from query, as there are no other known ports, fix docstrings

* Revise docstrings, remove superfluous information and remove unused methods ({set,get_icon} and set_time)

* cli: indent device output to make it more easily readable when having multiple devices

* remove adjust flake8 ignores (we have no setup.py anymore)

* pyproject: include cli tool to coverage, add config for interrogate (docstring coverage)

* bulb: raise exception on color_temp error cases instead of returning zero values

* improve bulb tests, simplify conftest

* strip: rename plugs property to children and move it to smartdevice
2020-05-27 16:55:18 +02:00
Teemu R
836f1701b9
Optimize I/O access (#59)
* Optimize I/O access

A single update() will now fetch information from all interesting modules,
including the current device state and the emeter information.

In practice, this will allow dropping the number of I/O reqs per homeassistant update cycle to 1,
which is paramount at least for bulbs which are very picky about sequential accesses.
This can be further extend to other modules/methods, if needed.

Currently fetched data:
* sysinfo
* realtime, today's and this months emeter stats

New properties:
* emeter_realtime: return the most recent emeter information, update()-version of get_emeter_realtime()
* emeter_today: returning today's energy consumption
* emeter_this_month: same for this month

Other changes:
* Accessing @requires_update properties will cause SmartDeviceException if the device has not ever been update()d
* Fix __repr__ for devices that haven't been updated
* Smartbulb uses now the state data from get_sysinfo instead of separately querying the bulb service
* SmartStrip's state_information no longer lists onsince for separate plugs
* The above mentioned properties are now printed out by cli
* Simplify is_on handling for bulbs

* remove implicit updates, return device responses for actions, update README.md instructions. fixes #61
2020-05-24 17:57:54 +02:00
Teemu R
012436c494
Improve dimmer support (#62)
* discover dimmers properly

* fix circular import, hopefully

* add is_color to SmartDevice API

* allow changing the dimming without implicitly turning the device on

* Add tests for device type handling for discovery data, make sure new fixtures are added to categories inside conftest
2020-05-20 21:17:33 +02:00
Teemu R
e37244de0f
Remove unnecessary f-string definition to make tests pass (#58) 2020-05-13 14:50:45 +02:00
Teemu R
ed57563e8b
Convert to use poetry & pyproject.toml for dep & build management (#54)
* Convert to use poetry and pyproject.toml, update README

* add some resources for contributors

* minor adjustments

* ci: separate tests from linting, run using poetry

* add pytest-mock to dev requirements

* combine running tests and reporting to codecov

* generate both xml and html coverage reports

* add codecov to dev dependencies
2020-05-12 12:11:47 +02:00
Teemu R
c6d76836d7
Add fixture for KL60 (#52) 2020-04-26 17:44:16 +02:00
Teemu R
51af7809ec
Ignore D202 where necessary (#50)
This is required as https://github.com/PyCQA/pydocstyle/pull/426 does not
fix the issue for async def'd inner functions.
2020-04-25 21:21:39 +02:00
Teemu R
28c1811aef
Support wifi scan & join for bulbs using a different interface (#49) 2020-04-24 17:57:04 +03:00