Commit Graph

26 Commits

Author SHA1 Message Date
Ville Skyttä
752b24c4ec Python < 3.5 cleanups (#180)
* tox: remove Python < 3.5 config

* deps: drop typing, included in Python 3.5+
2019-08-13 16:55:18 -04:00
Teemu R
2d60467bea
API and tests cleanup (#151)
* Add new cli commands: raw_command and dump_discover

- raw_command can be used to execute raw commands with given parameters
  * Useful for testing new calls before implementing them properly

- dump_discover can be used to dump the device discovery information (into a file)
  * The discovery is extended to request more modules and methods from devices
    * smartlife.iot.dimmer get_dimmer_parameters
    * smartlife.iot.common.emeter get_realtime
    * smartlife.iot.smartbulb.lightingservice get_light_state
  * This is used to dump more information for proper tests, and will also allow better discovery in the future

This commit contains also some documentation updates and dropping click_datetime in favor of click's built-in datetime

* Docstring fixes

* Major API cleanup

Properties shall no more change the state of the device, this work in still in progress, the main goal being making the API more user-friendly and to make implementing new features simpler.

The newly deprecated functionality will remain working and will simply warn the user about deprecation.
Previously deprecated 'features' property and 'identify' method are now finally removed.

Deprecate and replace the following property setters:
* state with turn_on() and turn_off()
* hsv with set_hsv()
* color_temp with set_color_temp()
* brightness with set_brightness()
* led with set_led()
* alias with set_alias()
* mac with set_mac()

And getters:
* state with is_on and is_off

The {BULB,PLUG}_STATE_{ON,OFF} is simplified to STATE_ON and STATE_OFF, UNKNOWN state is removed.
These are now deprecated and will be removed in the future.
* is_on and is_off can be used to check for the state
* turn_on() and turn_off() for changing the device state.

Trying to use functionality not supported by the device will cause SmartDeviceExceptions instead of failing silently and/or returning None.
This includes, e.g., trying to set a color temperature on non-supported bulb.

ValueErrors are raised instead of SmartDeviceExceptions where appropriate (e.g. when trying to set an invalid hsv or brightness).

New enum type DeviceType is added to allow detecting device types without resorting to isinstance() calling. SmartDevice class' device_type property can be used to query the type. is_plug and is_bulb helpers are added.

* Cleanup tests and improve test coverage

* Make writing tests easier by sharing code for common implementations
* Instead of storing test data inside python files, dump-discover based information is used
  * This will simplify adding new tests and remove code duplication
  * fixtures are based on https://github.com/plasticrake/tplink-smarthome-simulator

* run black on newfakes

* Add HS300 tests and update SmartStrip API according to earlier changes, still WIP

* run black and avoid wildcard imports

* Black on conftest

* bump minimum required version to 3.5

* Rename fixture_tests to test_fixtures for autocollect

* fix typoed type to _type, black

* run black on several files with -79 to fix hound issues

* Fix broken merge on hue

* Fix tests (hue update, pass context to smartdevice), add is_strip property, disable emeter tests for HS300 until a solution for API is found.

* Fix old tests

* Run black on changed files

* Add real HS220 discovery, thanks to @poiyo

* add is_dimmable and is_variable_color_temp to smartdevice class, simplifies interfacing with homeassistant

* add KL120(US) fixture

* Add a simple query cache

This commit adds a simple query cache to speed up the process for users
requesting lots of different properties from the device, as done by the
cli tool as well as homeassistant.

The logic for caching is very simple:
1. A timestamp for last fetch for each module+command is stored alongside the response.
2. If the issued command starts with `get_` and the TTL has not expired, the cache result is returned.
3. Otherwise the cache for the whole corresponding module gets invalidated, the device will be queried and the result will be stored in the cache.

* add deprecation to tox.ini

* make tests pass again

* remove old tests, add flake8 to tox reqs

* run black against pyhs100 module, add it to precommit hooks, fix flake8 configuration to conform to black standards (https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/)

* fix syntax

* cleanup conftest
2019-06-16 17:05:00 -04:00
Teemu R
29f75d9566
Prepare 0.3.5 (#170) 2019-04-13 01:12:37 -04:00
Teemu R
c4bb48979f
Prepare 0.3.4 (#154) 2019-01-17 11:39:51 +01:00
Teemu R
d72b47c0b7
Prepare 0.3.3 (#128) 2018-09-06 16:52:11 +02:00
Teemu R
e612560b35
Bump for 0.3.2 (#123) 2018-06-17 19:04:24 +02:00
Teemu R
caa01befd7
Release 0.3.1 (#121)
* update changelog, bump version to 0.3.1

* fix flake8
2018-06-16 21:31:51 +02:00
Teemu R
11a7042a04
update pypi description (#102)
* update pypi description

* add wall switches
2018-06-09 17:45:10 +02:00
Teemu Rytilahti
4c427a8413 Add python_requires for >= 3.4 2018-01-21 00:48:48 +01:00
Teemu R
b80923061f Release 0.3.0 (#88)
* update the changelog

* revise README, fixes #86

* bump the version

* final changelog update for 0.3.0
2017-10-07 17:51:10 +02:00
Teemu R
af90a36153 add typing hints to make it easier for 3rd party developers to use the library (#90)
* add typing hints to make it easier for 3rd party developers to use the library

* remove unused devicetype enum to support python3.3

* add python 3.3 to travis and tox, install typing module in setup.py
2017-09-18 18:13:06 +02:00
Teemu R
86f14642c8 Refactor and drop py2 support (#49)
* move is_off property to SmartDevice, implement is_on for bulb and use it

* refactor by moving smartbulb and smartplug to their own classes

* drop python2 compatibility, make flake8 happy

* travis: remove 2.7, add 3.6
2017-04-14 14:24:58 +02:00
Teemu R
c9662fcb7b add future requirement (#47)
bump the version & add future requirement
2017-04-08 01:58:20 +02:00
Teemu Rytilahti
23e51a8686 cli: display an error if no ip is given
also bump the version to 0.2.4.1 with this fix.
2017-03-26 03:22:18 +02:00
Teemu R
b1cc0fd3f6 Release 0.2.4 preparations (#43) 2017-03-25 23:04:32 +01:00
Teemu R
d253b55d41 Add new client tool (#42)
* Add new client tool

After installing the package pyhs100 command-line tool can be used
to control the plug.

See --help for its usage, most of the features for plugs are implemented,
some of the shared functionality works for bulbs too.

* Add discover command

* Delete old examples, the cli works as an example well enough
2017-03-20 19:03:19 +01:00
GadgetReactor
04185706f8 Version bump 2017-01-11 16:20:04 +08:00
Georgi Kirichkov
45fc354888 Version bump (#16) 2016-12-13 14:50:40 +08:00
GadgetReactor
53c06ca784 HS200 support
Update version to reflect latest changes
2016-11-14 09:56:11 +08:00
GadgetReactor
1f771b7d80 Merge pull request #2 from kirichkov/energy-monitoring
Adds energy monitoring functionality available in the HS110 plugs
2016-10-19 16:10:00 +08:00
GadgetReactor
d4be10ff26 Update setup.py 2016-10-18 09:41:13 +08:00
Georgi Kirichkov
3744a075c3 Bumps the module version to 0.2.0 2016-10-17 15:36:07 +03:00
GadgetReactor
4653e60de0 0.1.2 2016-07-09 20:27:58 +08:00
GadgetReactor
25a5ede746 Update setup.py 2016-07-09 20:24:50 +08:00
GadgetReactor
358ca42f48 Update setup.py 2016-07-09 19:55:10 +08:00
GadgetReactor
4ef443da0f Create setup.py 2016-07-09 19:32:16 +08:00