Commit Graph

52 Commits (e525d13a5d8a27bd9ce72138d3a6cd8af31040ea)

Author SHA1 Message Date
Anders Melchiorsen 81a27e726c Upgrade aiolifx (#8648)
This release includes a fix for multizone lights with zone counts that are not
a multiple of eight.
2017-07-26 12:33:00 +02:00
Anders Melchiorsen 8a42e1551a LIFX: assume default features for unknown products (#8553)
This makes the detection work for prototypes as well.
2017-07-19 22:54:46 -07:00
Anders Melchiorsen 4fde0ffe9c LIFX: support for multizone (#8399)
* Make aiolifx modules easily available

* Use aiolifx features_map for deciding bulb features

Also move the feature detection out of Light so it is available even
during the initial detection.

* Move each LIFX light type to a separate class

* Simplify AwaitAioLIFX

This has become possible with recent aiolifx that calls the callback even
when a message is lost.

Now the wrapper can be used also before a Light is added though the register
callback then has to become a coroutine.

* Refactor send_color

* Add support for multizone

This lets lifx_set_state work on individual zones.

Also update to aiolifx_effects 0.1.1 that restores the state for individual
zones.
2017-07-13 19:38:36 -07:00
Anders Melchiorsen bb9db28c95 LIFX: make broadcast address configurable (#8453) 2017-07-12 23:08:18 +02:00
Anders Melchiorsen d10f017441 LIFX: improve light availability (#8451)
The default aiolifx timers are tuned for a network with few lost packets.
This means that lights can become "unavailable" from just a two second
dropout. An unavailable light is completely useless for HA until it is
rediscovered so this is an undesirable state to be in.

These tweaks make aiolifx try harder to get its messages through to the
bulbs, at the cost of some latency in detecting lights that actually are
unavailable.
2017-07-12 19:24:24 +02:00
Anders Melchiorsen 6c9742afc4 Update aiolifx (#8396) 2017-07-07 19:57:14 +02:00
Anders Melchiorsen a328df6014 LIFX: Small code cleanups (#8228) 2017-06-30 02:10:28 +02:00
Anders Melchiorsen af54311718 LIFX: Move light effects to external library (#8222)
* LIFX: Move light effects to external library

This moves the LIFX light effects to the external library aiolifx_effects.

To get the light state synchronized between that library and HA, the LIFX
platform no longer maintains the light state itself. Instead, it uses the
cached state that aiolifx maintains.

The reorganization also includes the addition of a cleanup handler.

* Fix style
2017-06-26 22:05:32 -07:00
Anders Melchiorsen d4b085081a LIFX light effects (#7145)
* Refactor into find_hsbk

This will be useful for new methods that also have to find passed in colors.

* Add AwaitAioLIFX

This encapsulates the callback and Event that aiolifx needs and thus avoids an
explosion of those when new calls are added.

The refresh_state is now generally useful, so move it into its own method.

* Initial effects support for LIFX

These effects are useful as notifications. They mimic the breathe and pulse
effects from the LIFX HTTP API:

    https://api.developer.lifx.com/docs/breathe-effect
    https://api.developer.lifx.com/docs/pulse-effect

However, this implementation runs locally with the LIFX LAN protocol.

* Saturate LIFX no color value

Now the color is "full saturation, no brightness". This avoids a lot of
temporary white when fading from the "no color" value and into a real color.

* Organize LIFX effects in classes

This is to move the setup/restore away from the actual effect, making it quite
simple to add additional effects.

* Stop running LIFX effects on conflicting service calls

Turning the light on/off or starting a new effect will now stop the running
effect.

* Present default LIFX effects as light.turn_on effects

This makes the effects (with default parameters) easily accessible from
the UI.

* Add LIFX colorloop effect

This cycles the HSV colors, so that is added as an internal way to set a
color.

* Move lifx to its own package and split effects into a separate file

* Always show LIFX light name in logs

The name is actually the easiest way to identify a bulb so just using it
as a fallback was a bit odd.

* Compact effect getter

* Always use full brightness for random flash color

This is a stopgap. When a bit more infrastructure is in place, the intention
is to turn the current hue some degrees. This will guarantee a flash color
that is both unlike the current color and unlike white.

* Clear effects concurrently

We have to wait for the bulbs, so let us wait for all of them at once.

* Add lifx_effect_stop

The colorloop effect is most impressive if run on many lights. Testing
this has revealed the need for an easy way to stop effects on all lights
and return to the initial state of each bulb. This new call does just that.

Calling turn_on/turn_off could also stop the effect but that would not
restore the initial state.

* Always calculate the initial effect color

To fade nicely from power off, the breathe effect needs to keep an
unchanging hue. So give up on using a static start color and just find the
correct hue from the target color.

The colorloop effect can start from anything but we use a random color
just to keep things a little interesting during power on.

* Fix lint

* Update .coveragerc
2017-04-20 22:46:12 -07:00
Anders Melchiorsen d4b05a6a85 Fix LIFX lights with disappearing names (#7119)
* Cache the name of LIFX lights

After #7031 the LIFX device will change during an unregister/register
transition. This has the user-visible effect of the new device missing
a friendly name until the next poll.

We now cache the name internally and it will then transfer to the new
device when it registers.

* Allow LIFX logging even without an available device

This will allow us to set the device to None when it unregisters.

* Calculate LIFX availability from the existence of a device

This has become possible because the device is no longer needed
to provide the name of the light when it is unavailable.

We just have to forget the device when it unregisters.
2017-04-16 17:40:22 -07:00
Anders Melchiorsen f099aee69a Plug file leak on LIFX unregister (#7031)
* Plug file leak on LIFX unregister

The aiolifx 0.4.4 release closes its socket when the unregister callback is
called. This plugs a file descriptor leak but also means that we must be
careful to not use the device after it goes unavailable.

Also, when a light reappears, it has a new device that must be used.

* Do not test self.available in service calls

The core will learn to handle that.
2017-04-11 08:58:51 -07:00
David McNett c27a526f5b Eliminate needless async_add_job invocation of async_add_devices (#6864) 2017-04-03 00:01:53 -07:00
Anders Melchiorsen 7b83a836f3 Lifx legacy (#6847)
* Add legacy LIFX platform for Windows support

The async platform introduced in 9ef084d903 has
turned out to use Python functionality that is not available in Windows.

This commit restores the previous implementation, now named lifx_legacy.

* Add a comment about the platform being a legacy implementation

* Warn when using unsupported lifx platform on Windows

* Update .coveragerc
2017-03-29 23:00:22 -07:00
Anders Melchiorsen ba3c9f9765 Fix LIFX unregister races (#6723)
* Fix LIFX unregister races

If the initial state request never got a response, we tried to unregister
a device that was not yet registered.

Also, aiolifx 0.4.2 has an "unregister" race fix.

* Update requirements
2017-03-21 07:17:58 +01:00
Anders Melchiorsen 9ef084d903 Move LIFX to aiolifx for driving the bulbs (#6584)
* Move LIFX to aiolifx for driving the bulbs

* Fix whitespace

* Fix more whitespace

* Fix lint

* Define _available in init

* Add @callback decorators

* Use hass.async_add_job

* Rename class
2017-03-15 22:50:33 -07:00
Anders Melchiorsen 7774f0ae53 Set new color before turning LIFX bulbs on (#6402)
A LIFX bulb maintains its previous color even when the light is off.
For example, if the previous color is blue and the bulb is turned on
and then set to a red color, it will transition through purple colors.

After this commit, the target color is set while the bulb is still
turned off. This overrides the previous color and brightness that the
bulb remembered. The light is then turned on with the requested
transition duration.

For the example, this gives the expected result of only going through
red colors.
2017-03-05 11:11:33 +01:00
Pascal Vizeli 8232f1ef65 Cleanup async handling (#6388)
* Cleanups unneeded blocks

* Cleanup bootstrap

* dedicated update_ha_state

* Fix imap_email_content

* fx tests

* Fix lint & spell
2017-03-04 15:10:36 -08:00
Nate d5bdf7783e light.transition now supports float instead of int in order to be able to perform faster transitions (#6163) 2017-02-26 21:21:12 -08:00
kitcorey 75df4be733 Fix colortemp conversion for lifx lights (#6087) 2017-02-18 20:42:57 +02:00
Fabian Affolter be272ac64a Disable too-many-* (#4107)
* Disable too-many-* and too-few-public-methods

* Remove globally disabled pylint warnings
2016-10-30 22:18:53 +01:00
Fabian Affolter f5df5615be Migrate to voluptuous (#3282) 2016-09-11 10:04:07 +02:00
Assaf Inbal 72ad1d8d7c Added support for exposing light features (#2828) 2016-08-15 23:07:07 -07:00
Fabian Affolter e06ff95107 Remove pylint disable (#2785) 2016-08-11 12:00:37 +02:00
Brad Johnson 09693bf16c Upgrading to python-wink 0.7.4 and improving RGB color support in HA (#1832) 2016-04-17 19:07:21 -07:00
Fabian Affolter 7e8e91ef3c Fix PEP257 issues 2016-03-07 22:08:21 +01:00
Paulus Schoutsen e80309c03c Fix imports (using isort) 2016-02-18 21:27:50 -08:00
Tim 08ab7dba2c Fix whitespace 2016-02-02 00:21:15 +00:00
Tim 031e7a4013 New liffylights release improves device detection
Increase device polling to 30 seconds
2016-02-02 00:15:38 +00:00
Paulus Schoutsen b21be63220 Merge pull request #1066 from TangoAlpha/dev
Update for new liffylights release
2016-01-31 08:32:51 -08:00
Tim 1974eda51d Update for new liffylights release
Fix incorrect packet timeout/ack code causing flooding when no bulbs were online, which consumed all WorkerPool threads
2016-01-31 13:31:12 +00:00
Paulus Schoutsen 3e35bc06fc Merge pull request #1055 from TangoAlpha/dev
Update to new release of liffylights
2016-01-30 12:56:22 -08:00
Tim f76dee8a05 Update to new release of liffylights 2016-01-30 20:48:57 +00:00
Fabian Affolter 94d2f23cfc Add link to docs and remove configuration details 2016-01-27 08:08:04 +01:00
Tim b1ba792715 Brightness from HA overrides brightness from HSV conversion 2016-01-25 21:19:27 +00:00
Tim 1397f9e588 Fix logging typo 2016-01-25 20:58:10 +00:00
Tim bb7f92330d Update liffylights version 2016-01-25 20:53:21 +00:00
Tim 784fea2d56 Update for new liffylights version 2016-01-25 19:08:48 +00:00
Tim 11120a8743 Fix liffylights import 2016-01-25 15:19:50 +00:00
Tim 8009542b3e Add extra debugging
Add duration to power on
2016-01-25 13:30:52 +00:00
Tim d10a5cf5e9 Update to v0.8.3 of liffylights 2016-01-25 11:54:41 +00:00
Tim 5a926913d3 Update to v0.6 of liffylights 2016-01-25 10:00:15 +00:00
Tim 50561ffe97 Fix long line 2016-01-25 03:39:13 +00:00
Tim 74e8446556 Bump version of liffylights 2016-01-25 03:34:24 +00:00
Tim d94db5388c Add preliminary support for transition time 2016-01-25 03:32:55 +00:00
Tim 6d2bca0fd1 Import 3rd party library inside method 2016-01-24 01:13:51 +00:00
Tim 99286391e1 Fixes for lint 2016-01-24 01:00:02 +00:00
Tim 711f2da496 Update liffylights version 2016-01-24 00:43:50 +00:00
Tim 58034219b6 Bump version liffylights 2016-01-23 22:23:46 +00:00
Tim 17f5a466d9 Separate LIFX code and HA component 2016-01-23 22:14:57 +00:00
Tim 3d23cd10fc Attempt to fix ungrouped-imports pylint error 2016-01-18 18:30:09 +00:00