Commit Graph

26 Commits

Author SHA1 Message Date
Annika Jacobs
4cb28a3b25 Updated valid range to 360 (with passing tests) (#153)
* Updated valid range to 360

with it set to 359 it will not show the color red. Just tested this with a buddies bulb - same model/fw
https://imgur.com/a/kSNZIuL

* Updated valid range to 360

with it set to 359 it will not show the color red. Just tested this with a buddies bulb - same model/fw
https://imgur.com/a/kSNZIuL

* Update valid range to 360

* Fix tests
2019-01-16 21:50:48 +01:00
jimboca
6115d96c39 Add support for HS300 power strip (#137)
* discover runs, prints on since of device 0

* added preliminary support for HS300

* forgot to add smartdevice to commit

* added index to CLI

* clean up dirty code

* added fake sysinfo_hs300

* changed device alias to match MAC

* #131 Move _id_to_index into smartstrip so everyone can pass index

* Update pyHS100/discover.py

Co-Authored-By: jimboca <jimboca3@gmail.com>

* refactoring to deduplicate code between smarplug and smartstrip

* fixing CI failures for devices without children

* incorporating feedback from pull request.

* fixing hound violation

* changed internal store from list of dicts to dict

* changed other methods to dictionary store as well

* removed unused optional type from imports

* changed plugs to Dict, remove redundant sys_info calls

* added more functionality for smart strip, added smart strip tests

* updated FakeTransportProtocol for devices with children

* corrected hound violations

* add click-datetime
2019-01-08 20:13:25 +01:00
Annika Jacobs
c65d4c0b30 Change valid hue range to 0-359 (fixes #130), update README.md & test (#140)
* Change valid hue range to 0-359 (fixes #130)

Tested on LB130(EU) hardware 1.0, firmware 1.8.6 Build 180809 Rel.091659

Co-Authored-By: nkonopinski <nkonopinski@users.noreply.github.com>

* Update README.md

* Update test_bulb.py
2018-11-16 23:18:28 +01:00
Teemu Rytilahti
55fca7ed44 add missed test for invalid types 2018-10-18 20:19:10 +02:00
Teemu Rytilahti
8d4f4a6de3 Add tests and pretty output for HS220, fix minor issues in tests 2018-10-18 19:57:44 +02:00
Sebastian Templ
df0a7f4c36 Fix bug that changed brightness at each HSV update (#124)
* Fix bug that changed brightness at each hsv update

The HSV setter should accept a percentage for the brightness
value but actually assumed the brightness to be in absolute values
between 1 and 255.
This resulted in brightness reductions at each HSV update, in
steps of 100% -> 100/255=39% -> 39/255=15% -> ... (see also
https://github.com/home-assistant/home-assistant/issues/15582,
where I originally reported this bug).

* Modify HSV property to return brightness in percent

Switch from reported brightness values of 1..255 to percentage
values, for consistency with the apidoc and 8761dd8.

* Add checks and tests for the hsv setter

- make sure that new (hue, saturation, brightness) values are
  within their valid ranges (0..255, 0..100, 0..100) and raise
  SmartDeviceException if they are not
- add test function for the hsv setter
2018-09-05 22:44:44 +02:00
Anders Melchiorsen
a6d515b5cb Support Unicode strings in encrypt/decrypt (#125) 2018-08-08 16:52:03 +02:00
Thibault Cohen
c6739daacc Add bulb valid temperature range (#122) 2018-06-17 19:01:18 +02:00
Teemu R
ef2e21ff69
Fix emeter support for newer HS110 firmwares (#107)
* Add support for new-style emeter

This commit adds a straightforward dict-extending container,
which converts between the old and new keys of the get_emeter_realtime()
Furthermore the unit tests are converted to base on HS100
instead of HS110.

This is the first step to fix #103, other emeter-using functionality
has not yet been converted, only getting the current consumption.

* fix a couple of linting issues

* Convert new-style emeter values also for get_emeter_daily() and get_emeter_monthly()

* Adds a new 'kwh' parameter for those calls, which defaults to True
* This changes the behavior of bulbs emeter reporting, use False if you prefer the preciser values
2018-06-16 21:16:35 +02:00
Teemu R
0b2e371e79 move SmartDeviceException to SmartDevice, and remove types.py complet… (#95)
* move SmartDeviceException to SmartDevice, and remove types.py completely. fixes #94

* do not import skipIf anymore
2017-10-07 17:41:51 +02:00
Teemu R
d22eceefae move has_emeter implementation from SmartDevice to SmartPlug, avoid using features() internally (#93)
* move has_emeter implementation from SmartDevice to SmartPlug, avoid using features() internally

* add stacklevel to deprecation warnings to see where they are really called

* make tests pass on a real device. if PLUG_IP is not None, the tests will be run on a device at the defined IP address
2017-10-07 17:36:49 +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
3a14484d47 add lb120 sysinfo to test suite, thanks to githubbuh (#85) 2017-08-30 03:35:34 +03:00
Teemu R
8f83ca8784 add lb100 tests, thanks to kdschlosser (issue #58) (#82) 2017-08-22 16:55:49 +02:00
Teemu Rytilahti
651331bb77 allow None for rssi, add a missing newline to fakes.py 2017-08-05 17:33:08 +02:00
Teemu Rytilahti
d648c6bd2b add hs100 tests 2017-08-05 17:30:40 +02:00
Teemu Rytilahti
675f618777 make tests to test against all known device variants 2017-08-05 17:30:40 +02:00
Teemu Rytilahti
5839c2d1de fix hs105 mac to pass the test, wrap sysinfo_lb110 properly inside 'system' 2017-08-05 17:30:40 +02:00
Teemu R
d15e7be4f3 add hs100 example to fakes.py, thanks to Semant1ka on #67 (#74) 2017-08-05 16:28:11 +02:00
Sean Gollschewsky
d7aade4e61 Add LB110 sysinfo (#75)
* Add LB110 sysinfo

* Linting.
2017-08-05 15:47:41 +02:00
Teemu Rytilahti
7457ad48f8 extract shared types (exceptions, enums), add module level doc, rename exception to be generic 2017-05-26 16:12:52 +02:00
Matt LeBrun
93d24281c6 Add check to ensure devices with lat/lon with _i suffix are supported (#54) (#56)
* Add check to ensure devices with lat/lon with `_i` suffix are supported (#54)

* Add .gitignore for posterity
2017-04-26 18:43:50 +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
Matthew Garrett
2d6376b597 Add support for TP-Link smartbulbs (#30)
* Add support for new-style protocol

Newer devices (including my LB130) seem to include the request length in
the previously empty message header, and ignore requests that lack it. They
also don't send an empty packet as the final part of a response, which can
lead to hangs. Add support for this, with luck not breaking existing devices
in the process.

* Fix tests

We now include the request length in the encrypted packet header, so strip
the header rather than assuming that it's just zeroes.

* Create a SmartDevice parent class

Add a generic SmartDevice class that SmartPlug can inherit from, in
preparation for adding support for other device types.

* Add support for TP-Link smartbulbs

These bulbs use the same protocol as the smart plugs, but have additional
commands for controlling bulb-specific features. In addition, the bulbs
have their emeter under a different target and return responses that
include the energy unit in the key names.

* Add tests for bulbs

Not entirely comprehensive, but has pretty much the same level of testing
as plugs
2017-01-17 21:38:23 +08:00
Teemu R
76cc597c2a Make tests runnable without device (#24)
* Make tests runnable without device

Adds preliminary support for fake devices, thanks to
hoveeman's sysinfos from issue #14,
making running tests possible without a device.

At the moment we have only HS110 and HS200 infos available, and tests
are currently run only against HS110 data.

* Make tests py27 compatible
2017-01-08 06:45:47 +08:00
Teemu R
fd4e363f56 Refactor & add unittests for almost all functionality, add tox for running tests on py27 and py35 (#17)
* Refactor & add unittests for almost all functionality, add tox for running tests on py27 and py35

This commit adds unit tests for current api functionality.
- currently no mocking, all tests are run on the device.
- the library is now compatible with python 2.7 and python 3.5, use tox for tests
- schema checks are done with voluptuous

refactoring:
- protocol is separated into its own file, smartplug adapted to receive protocol worker as parameter.
- cleaned up the initialization routine, initialization is done on use, not on creation of smartplug
- added model and features properties, identity kept for backwards compatibility
- no more storing of local variables outside _sys_info, paves a way to handle state changes sanely (without complete reinitialization)

* Fix CI warnings, remove unused leftover code

* Rename _initialize to _fetch_sysinfo, as that's what it does.

* examples.cli: fix identify call, prettyprint sysinfo, update readme which had false format for led setting

* Add tox-travis for automated testing.
2016-12-17 06:51:56 +08:00