* 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
* Added option to control devices by device name
* set unused ip address to dont-care
* spend less time discovering by devicename, removed command
* consistent use of alias instead of device name
* processed review comments
* Return when no device with alias has been found
* add 'alias' command for querying and setting the alias
* calculate coverage only on library files, e.g., ignoring cli and test files
* remove py34 and add py37
* readd py33, remove it from travis as it seems to be a travis limitation only
* use xenial dist for travis, regular does not support py37..
* 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
* Update smartplug.py to support dimming in HS220
Switch functions essentially as a "plug" with the addition to support for dimming, for which can be test for by verifying existence of 'brightness' array value.
* Attempt at updates to pass validator
* Maybe this time? :-)
* Add more detail to comment blocks
Make clear in requests for current brightness level the expected return values, and note that light will turn on when setting a brightness level, if not already on. This makes clear that a state change request (turn_on) does NOT have to be made first when setting brightness.
* Update smartplug.py
* Update smartplug.py
Fixes#114
* 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
* 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
* Discover refactoring, enhancements to the cli tool
* Discover tries to detect the type of the device from sysinfo response
* Discover.discover() returns an IP address keyed dictionary,
values are initialized instances of the automatically detected device type.
* When no IP is given, autodetect all supported devices and print out their states
* When only IP but no type is given, autodetect type and make a call based on that information.
* One can define --bulb or --plug to skip the detection.
* renamed pyHS100.py -> smartdevice.py
* SmartPlugException -> SmartDeviceException in comments
* fix mic_type check
* make time() return None on failure as we don't know which devices support getting the time and it's used in the cli tool
* hw_info: check if key exists before accessing it, add mic_mac and mic_type
* Check for mic_mac on mac, based on work by kdschloesser on issue #59
* make hound happy, __init__ on SmartDevice cannot error out so removing 'raises' documentation
Fixes#48 and #51. The basic functionality should work on all types of supported devices, for bulb specific commands it is currently necessary to specify ```--bulb```.
* 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
* 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
* 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
This commit removes caching of sysinfo to avoid
inconsistent states as described in issue #14.
Each an every access for properties will cause a request
to be made to the device. To avoid this, user of the library
may want to access sys_info() directly instead of using the helpers.
Currently sys_info() returns raw json object where-as helpers do
parse information for easier consumption; current state is just to
provide a PoC how it looks compared to having an active update()
for fetching the info.
* 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
* add (untested) discover mode
* Keep discovery and normal communication separate, uppercase magic consts
This sepearates the earlier test code for discovering devices,
and adds 5 sec timeout for gathering responses from potential devices.
This commit also uppercases magic constants.
Discovery & communication tested with HS110.
* update readme with example how to discover devices, pep8ify