Skip to content

Migrate lifx light to color_mode#69420

Merged
emontnemery merged 4 commits intodevfrom
lifx_light_color_mode
Apr 28, 2022
Merged

Migrate lifx light to color_mode#69420
emontnemery merged 4 commits intodevfrom
lifx_light_color_mode

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

Proposed change

Migrate lifx light to color_mode

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • 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:

@emontnemery emontnemery marked this pull request as draft April 6, 2022 13:05
return support
def color_mode(self) -> str:
"""Return the color mode of the light."""
return COLOR_MODE_HS
Copy link
Copy Markdown
Contributor Author

@emontnemery emontnemery Apr 6, 2022

Choose a reason for hiding this comment

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

Is this correct, or can the LIFXColor and its subclasses support white with adjustable color temperature too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LIFXColor devices all support COLOR_MODE_COLOR_TEMP as well as COLOR_MODE_HS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @Djelibeybi 👍

Does it mean this check is not needed, and supported color modes are always hs + color_temp?

        if bulb_features["min_kelvin"] != bulb_features["max_kelvin"]:
            return COLOR_MODE_COLOR_TEMP

Also, it looks like the API sends a tuple (h, s, b, kelvin) to the light.
What does the light do if saturation is not None, is the kelvin parameter ignored or still relevant?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For color bulbs, they all support both modes. If min_kelvin == max_kelvin then the bulb only supports brightness adjustment.

if saturation > 0, the kelvin value is ignored.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, so would this be correct:

diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py
index 323bec3f1d..5aeeb13d3e 100644
--- a/homeassistant/components/lifx/light.py
+++ b/homeassistant/components/lifx/light.py
@@ -571,10 +571,6 @@ class LIFXLight(LightEntity):
         """Flag supported features."""
         support = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_EFFECT

-        bulb_features = lifx_features(self.bulb)
-        if bulb_features["min_kelvin"] != bulb_features["max_kelvin"]:
-            support |= SUPPORT_COLOR_TEMP
-
         return support

     @property
@@ -728,7 +724,7 @@ class LIFXColor(LIFXLight):
     def supported_features(self):
         """Flag supported features."""
         support = super().supported_features
-        support |= SUPPORT_COLOR
+        support |= SUPPORT_COLOR | SUPPORT_COLOR_TEMP
         return support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This product seems to be a bulb with adjustable color temperature but without color support though: https://www.lifx.com/products/candle-white-to-warm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right, but it wouldn't be discovered as a LIFXColor bulb, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK updated so LIFXColor and LIFXStrip report support for color modes hs + color_temp.
If saturation is 0, the light will report the current mode as color_temp, else it will report hs.

@emontnemery emontnemery force-pushed the lifx_light_color_mode branch from 6e13007 to 67ca003 Compare April 26, 2022 14:32
Copy link
Copy Markdown
Contributor

@Djelibeybi Djelibeybi left a comment

Choose a reason for hiding this comment

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

Tested locally with my bulbs and it looks good.

@emontnemery emontnemery marked this pull request as ready for review April 27, 2022 06:27
@epenet epenet added the smash Indicator this PR is close to finish for merging or closing label Apr 27, 2022
@epenet epenet removed the smash Indicator this PR is close to finish for merging or closing label Apr 27, 2022
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

LGTM

@emontnemery emontnemery merged commit 59c6282 into dev Apr 28, 2022
@emontnemery emontnemery deleted the lifx_light_color_mode branch April 28, 2022 07:49
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants