Commit Graph

64 Commits

Author SHA1 Message Date
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
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
7f625cd1c2
Add commands to control the wifi settings (#45)
* Add commands to control the wifi settings

Enables initial provisioning and changing the wifi network later on without the official app

* new api to smartdevice: wifi_scan() and wifi_join(ssid, password, keytype)
* cli: new subcommand 'wifi' with two commands: scan and join

* update readme to initial setup

* improvements based on code review, f-strings++
2020-04-20 18:57:33 +02: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
Andrew May
b6c3a7c54b
Move has_emeter to device level for multiple plug outlets (#41) 2020-04-12 16:00:15 +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
Teemu R
e9b0acaaa7
Enable Windows & OSX builds (#31)
* Enable Windows & OSX builds

* Add pypy for ubuntu

* Fix isort

* Disable PyPy

typed-ast building fails due to a missing header
ast27/Parser/tokenizer.c:17:10: fatal error: codecs.h: No such file or directory
2020-03-18 00:40:06 +01: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
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
0f0df481a0
Add device_id property, rename context to child_id (#15)
For regular devices, device_id is the mac address and for child devices it is a combination of the mac address and the child_id.
2020-01-13 00:17:45 +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