Commit Graph

987 Commits

Author SHA1 Message Date
Teemu R
05a6bbb145 Read all data from the device, disable double-encoding, implement more APIs, refactor querying, update README (#11)
* Read from socket until no data available, disable double string encoding

HS110 sends sometimes datagrams in chunks especially for get_daystat,
this patch makes it to read until there is no more data to be read.

As json.dumps() does JSON encoding already, there's no need to str()
the year or month either.

* Add cli.py, a simple script to query devices for debugging purposes.

* allow easier importing with from pyHS100 import SmartPlug

* move cli.py to examples, add short usage into README.md

* Implement more available APIs, refactor querying code.

This commit adds access to new properties, both read & write,  while keeping the old one (mostly) intact.
Querying is refactored to be done inside _query_helper() method,
which unwraps results automatically and rises SmartPlugException() in case of errors.
Errors are to be handled by clients.

New features:
* Setting device alias (plug.alias = "name")
* led read & write
* icon read (doesn't seem to return anything without cloud support at least), write API is not known, throws an exception currently
* time read (returns datetime), time write implemented, but not working even when no error is returned from the device
* timezone read
* mac read & write, writing is untested for now.

Properties for easier access:
* hw_info: return hw-specific elements from sysinfo
* on_since: pretty-printed from sysinfo
* location: latitude and longitued from sysinfo
* rssi: rssi from sysinfo

* Update README.md with examples of available features.

* Handle comments from mweinelt

* Refactor state handling, use booleans instead of strings

* Fix issues raised during the review.

Following issues are addressed by this commit:
* All API is more or less commented (including return types, exceptions, ..)
* Converted state to use
* Added properties is_on, is_off for those who don't want to check against strings.
* Handled most issues reported by pylint.
* Adjusted _query_helper() to strip off err_code from the result object.
* Fixed broken format() syntax for string formattings.

* Fix ci woes plus one typo.

* Do initialization after changing device properties, fix nits.
2016-12-12 17:13:45 +08:00
GadgetReactor
1ffdc7bc67 Merge pull request #15 from mweinelt/master
Constants will be static members of SmartPlug
2016-12-05 08:54:27 +08:00
Martin Weinelt
109caaf9f6 Constants will be static members of SmartPlug 2016-12-04 23:01:06 +01:00
GadgetReactor
60dee92838 Merge pull request #13 from mweinelt/master
set up hound-ci
2016-12-04 11:51:03 +08:00
Martin Weinelt
1a9da33c21 set up hound-ci 2016-12-04 03:54:29 +01:00
GadgetReactor
fadb76c5a0 Merge pull request #8 from mweinelt/master
Externalize the TP-Link Smart Home Protocol
2016-11-22 21:29:19 +08:00
Martin Weinelt
cb5899e3cc
Normalize docstrings, address flake8 & pylint recommendations
Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
2016-11-22 02:32:11 +01:00
Martin Weinelt
33b2800fe8
Properly detect advertised features, expose alias
Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
2016-11-22 00:39:51 +01:00
Martin Weinelt
08fb487a06
Externalize the TP-Link Smart Home Protocol
Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
2016-11-21 23:18:12 +01:00
GadgetReactor
53c06ca784 HS200 support
Update version to reflect latest changes
2016-11-14 09:56:11 +08:00
GadgetReactor
9c39249b99 Merge pull request #5 from smaggard/add-hs200
Adding in support for the HS200 Wall switch referencing issues (#4)
2016-10-28 11:08:42 +08:00
Stephen Maggard
1550b6cb2e Adding in support for the HS200 Wall switch referencing issues (#4), simplifying model determination 2016-10-26 10:33:08 -05:00
Stephen Maggard
fe00041130 Adding in support for the HS200 Wall switch referencing issues (#4), simplifying model determination 2016-10-26 10:32:46 -05:00
Stephen Maggard
225bf47ace Adding in support for the HS200 Wall switch referencing issues (#4) 2016-10-26 09:56:26 -05: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
Georgi Kirichkov
61714ac110 Refactors state property to use get_info() and removes hs100_status() 2016-10-19 11:02:32 +03:00
Georgi Kirichkov
dc3de3fa10 Adds model check to current_consumption() and removes whitespace 2016-10-19 10:28:48 +03:00
Georgi Kirichkov
605abfdebb Fixes indentation and removes extra whitespaces 2016-10-18 10:59:30 +03:00
GadgetReactor
d4be10ff26 Update setup.py 2016-10-18 09:41:13 +08:00
GadgetReactor
b074a21c9a Update LICENSE
Updated to GPLv3 (instead of just copy and pasting)
2016-10-18 09:40:42 +08:00
Georgi Kirichkov
3744a075c3 Bumps the module version to 0.2.0 2016-10-17 15:36:07 +03:00
Georgi Kirichkov
9cd61fdcc8 Adds additional comments, for better compliance with the Apache license 2016-10-17 15:17:28 +03:00
Georgi Kirichkov
093899c588 Makes the socket sending code compatible with both Python 2 and python 3
Adds a shutdown to the socket used to send commands
2016-10-15 11:18:31 +03:00
Georgi Kirichkov
77d524ecf2 Refactors state() to use turn_on() and turn_off() 2016-10-13 18:33:50 +03:00
Georgi Kirichkov
0eabf264e4 Adds Energy Meter commands available on the TP-Link HS110
Also adds turn_on() and turn_off() commands to supplement the state
2016-10-13 18:31:34 +03:00
GadgetReactor
ef85f939fd Update pyHS100.py 2016-07-09 20:36:33 +08:00
GadgetReactor
89481ad06e Update __init__.py 2016-07-09 20:28:50 +08:00
GadgetReactor
f2a1daef94 Update __init__.py 2016-07-09 20:28:23 +08: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
244733a154 Delete pyHS100.py 2016-07-09 19:34:51 +08:00
GadgetReactor
faad2f080f Create pyHS100.py 2016-07-09 19:34:27 +08:00
GadgetReactor
3b51e66152 Create __init__.py 2016-07-09 19:33:19 +08:00
GadgetReactor
4ef443da0f Create setup.py 2016-07-09 19:32:16 +08:00
GadgetReactor
27dd078e57 Create pyHS100.py 2016-07-07 17:17:16 +08:00
GadgetReactor
639c1c822e Initial commit 2016-07-07 17:11:45 +08:00