Commit Graph

70 Commits

Author SHA1 Message Date
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
0c71957aa8
Return on_since only when its available and the device is on (#48)
* moves on_since property to smartdevice class, as it is not plug only
* returns None if the value is not available (some bulbs), or if the device is off
2020-04-24 17:47:57 +03:00
Teemu R
3fe578cf26
async++, small powerstrip improvements (#46)
* async++, small powerstrip improvements

* use asyncclick instead of click, allows defining the commands with async def to avoid manual eventloop/asyncio.run handling
* improve powerstrip support:
  * new powerstrip api: turn_{on,off}_by_{name,index} methods
  * cli: fix on/off for powerstrip using the new apis
* add missing update()s for cli's hsv, led, temperature (fixes #43)
* prettyprint the received payloads when debug mode in use
* cli: debug mode can be activated now with '-d'

* update requirements_test.txt

* remove outdated click-datetime, replace click with asyncclick

* debug is a flag

* make smartstripplug to inherit the sysinfo from its parent, allows for simple access of general plug properties

* proper bound checking for index accesses, allow controlling the plug at index 0

* remove the mess of turn_{on,off}_by_{name,index}, get_plug_by_{name,index} are enough.

* adapt cli to use that
* allow changing the alias per index

* use f-strings consistently everywhere in the cli

* add tests for get_plug_by_{index,name}
2020-04-21 20:46:13 +02:00
Teemu R
852ae494af
Add (some) tests to the cli tool (#22)
* Add tests to the cli tool

* add pytest-mock

* do not ignore cli.py for coverage

* read requirements_test.txt instead of redefining reqs in tox.ini

* Add upload to codecov, first try!

* fix name of the result file

* no need to manually publish to azure devops..
2020-04-20 20:26:20 +03:00
Teemu R
b73c0d222e
Move dimmer support to its own class (#34)
* Move dimmer support to its own class

SmartDimmer extends SmartPlug with brightness settings.
This will make the API of SmartPlug less confusing and will
make it simpler to downstream users to act with dimmers.

Fixes #33

* Lint & make tests pass

* Fix rebase after cache and emeter cleanups, hopefully everything went smoothly..

* oopsie, has_emeter was mistakenly included in smartplug
2020-04-18 23:35:39 +02:00
Teemu R
c90465c5dd
Remove unnecessary cache (#40)
The cache was useful trick when the property accesses caused I/O,
which is unnecessary now as dev.update() does explicitly cache results until its called again.
2020-04-12 15:57:49 +02:00
Andrew May
5ff299664e
Add in some new device types (#39)
* Add in some new device types

HS103 hardware 1.0 and 2.1
KP400

* Update conftest
2020-04-11 03:08:59 +02:00
J. Nick Koston
18d58388c1
Add test fixture for KL130 (#35)
* Add test fixture for KL130

* Update test
2020-04-10 16:16:50 +02:00
Teemu R
00276e34b7
Move child socket handling to its own SmartStripPlug class (#26)
* All child device handling is moved out from the main smartdevice class, which simplifies the code.
* This will also cleanup the constructors as only the subdevices require the ID and the parent reference.
* SmartStripPlug offers SmartPlug like interface, but does not allow separate updates
  * Trying to update() on the children will cause a warning.
2020-03-16 14:52:40 +01:00
Teemu R
489a550582
Add KP303 to the list of powerstrips (#28)
Should fix #27
2020-03-16 14:52:24 +01:00
Alex Cragg
15b0c8c0e6 Adding KP303 to supported devices (#25)
* Adding KP303(UK)_1.0.json

Adding the result file for the KP303 from kasa dump-discover

* Update readme to include KP303 as a supported device
2020-01-28 14:58:20 +01:00
Teemu R
80f097b5b3 use pytestmark to avoid repeating asyncio mark (#24) 2020-01-15 07:49:31 +01:00
Teemu R
72d6205ad2 Cleanup constructors by removing ioloop and protocol arguments (#23)
* Cleanup constructors by removing ioloop and protocol

* force kwarg for other arguments besides the host
2020-01-15 07:46:21 +01:00
Teemu R
7eea21f2dd
test the newly added device fixtures (#21)
* make fixture detection saner
* allow scrubbed locations
2020-01-14 19:16:30 +01:00
Angelo Gagliano
87c0dab8c8 Add real kasa device dumps (#18)
* Adds real kasa device dumps

* Adds newline to the end of the files
2020-01-14 13:34:57 +01:00
Teemu R
524d28abbc
Remove sync interface, add asyncio discovery (#14)
* do not update inside __repr__

* Convert discovery to asyncio

* Use asyncio.DatagramProtocol
* Cleanup parameters, no more positional arguments

Closes #7

* Remove sync interface

* This requires #13 to be merged. Closes #12.
* Converts cli to use asyncio.run() where needed.
* The children from smartstrips is being initialized during the first update call.

* Convert on and off commands to use asyncio.run

* conftest: do the initial update automatically for the device, cleans up tests a bit

* return subdevices alias for strip plugs, remove sync from docstrings

* Make tests pass using pytest-asyncio

* Simplify tests and use pytest-asyncio.
* Removed the emeter tests for child devices, as this information do not seem to exist (based on the dummy sysinfo data). Can be added again if needed.
* Remove sync from docstrings.

* Fix incorrect type hint

* Add type hints and some docstrings to discovery
2020-01-12 22:44:19 +01:00
Teemu R
3ef5086ffb mass rename to (python-)kasa (#1) 2019-12-18 09:11:18 +01:00