Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow LIFX bulbs to fade color even when off #46596

Merged
merged 2 commits into from
Feb 18, 2021

Conversation

emichael
Copy link
Contributor

Proposed change

LIFX bulbs have the capability to fade their color attributes even while the bulb is off. When the bulb is later turned on, the fade will continue as if the bulb was on all along. It would be nice to have this ability in home assistant automations.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

I'm not sure if the way I've done it is best. You could pull the if hsbk section out of the two branches of the conditional since it's the same in both now. I didn't know if the ordering of the commands mattered, though.

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

LIFX bulbs have the capability to fade their color attributes even while the bulb is off. When the bulb is later turned on, the fade will continue as if the bulb was on all along. It would be nice to have this ability in home assistant automations.

I'm not sure if the way I've done it is best. You could pull the `if hsbk` section out of the two branches of the conditional since it's the same in both now. I didn't know if the ordering of the commands mattered, though.
@homeassistant
Copy link
Contributor

Hi @emichael,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Comment on lines 611 to 614
if hsbk:
await self.set_color(ack, hsbk, kwargs)
await self.set_color(ack, hsbk, kwargs, duration=fade)
if power_on:
await self.set_power(ack, True, duration=fade)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if power_on is True? It is supposed to fade from black to the new color but I guess with this change it will start from whatever the color was before?

Copy link
Contributor Author

@emichael emichael Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amelchio I just tested it, and the bulb can fade color while it is fading power, and that is what happens.

We could switch it to check for hsbk and power_on and then use the old behavior then. That seems reasonable.

Alternatively, a user could emulate the old behavior by first changing the color without transition and then turning on the bulb with transition.

I think either way is fine.

@emichael
Copy link
Contributor Author

@amelchio I pushed a version that sets the color immediately when also fading the light on. I think that's the most intuitive behavior.

Copy link
Contributor

@amelchio amelchio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good 😃. Thanks!

@amelchio amelchio merged commit 8b97f62 into home-assistant:dev Feb 18, 2021
@emichael emichael deleted the patch-1 branch February 18, 2021 19:00
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants