Skip to content

Introduce support for color temperature#25503

Merged
balloob merged 3 commits into
home-assistant:devfrom
yeralin:dev
Jul 31, 2019
Merged

Introduce support for color temperature#25503
balloob merged 3 commits into
home-assistant:devfrom
yeralin:dev

Conversation

@yeralin
Copy link
Copy Markdown
Contributor

@yeralin yeralin commented Jul 26, 2019

Description:

flux_led component does not properly support all available modes that Flux Led Lights can operate in. In particular: warm-white mode (when controlled from a smart assistants Alexa/Google Home) and cool-white mode (cannot be set from Homeassistant at all).

Related issue (if applicable): fixes #23704

Checklist:

  • [✓ ] The code change is tested and works locally.
  • [✓ ] Local tests pass with tox. Your PR cannot be merged unless tests pass
  • [ ✓] There is no commented out code in this PR.

If the code does not interact with devices:

  • [✓ ] Tests have been added to verify that the new code works.

@cgtobi
Copy link
Copy Markdown
Contributor

cgtobi commented Jul 31, 2019

Please fix the linter errors.

@balloob balloob merged commit e1d884a into home-assistant:dev Jul 31, 2019
Copy link
Copy Markdown
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.

So I think it is awesome to get support for the second white channel (when available) but the PR seems quite rushed and honestly, I don't think it should have been merged in the current state. The PR is so determined to solve one use case involving Google Home that it forgets about all other situations.

I have added some comments but there are also a few things missing:

  • The color_temp property that SUPPORT_COLOR_TEMP implies is not implemented
  • Properties min_mireds and max_mireds are also not implemented.
  • There is an overlap with SUPPORT_WHITE_VALUE but it is not clear what it is.
  • I would expect the introduction of a call to getRgbww() to report the w2 brightness.
  • (Probably, a new MODE_RGBWW mode is needed to make everything click.)

Sorry if I got some points wrong; I don't have these bulbs so I go only by the code.


SUPPORT_FLUX_LED = (SUPPORT_BRIGHTNESS | SUPPORT_EFFECT |
SUPPORT_COLOR)
SUPPORT_COLOR | SUPPORT_COLOR_TEMP)
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.

This is wrong as now we are advertising support for color temperature with RGB (not just RGBW).

Comment thread homeassistant/components/flux_led/light.py
if color_temp is not None:
if brightness is None:
brightness = self.brightness
if color_temp == COLOR_TEMP_WARM_WHITE:
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.

I don't like this magic value. Using the frontend slider will give erratic behavior when this value is hit.

If only two temperatures are available I think it is better to decide a cutoff (like 3500 kelvin) and make all temperatures above/below the same.

But I will be surprised if only two temperatures are available since mixing w and w2 should give the full range of temperatures and that seems like a nice bullet on a feature list.

Copy link
Copy Markdown
Contributor Author

@yeralin yeralin Aug 1, 2019

Choose a reason for hiding this comment

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

You cannot mix w and w2 see #23704:

1. In order to activate warm white state, all values *but* `w` should be `None`, while `w` can be between 0 and 255. If any other parameter is not `None`, the call will not result in *any action*

2. In order to activate cool white state, all values *but* `w2` should be `None`, while `w2` can be between 0 and 255. If any other parameter is not `None`, the call will not result in *any action*

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.

Okay, maybe there is some product differentiation or maybe you found a bug. There is so much different flux_led hardware, I still don't think this is true for it all.

For example, this commit suggests white mixing is possible.

self._bulb.setRgbw(w2=brightness)
else:
self._bulb.setRgbw(
*color_util.color_temperature_to_rgb(color_temp))
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.

Don't do this conversion, it gives poor results and setting RGB is not what ATTR_COLOR_TEMP is for.

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.

Hmmm, what can be the alternative?

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.

Always set some white light even if it is the wrong temperature.

@yeralin
Copy link
Copy Markdown
Contributor Author

yeralin commented Aug 1, 2019

No worries, we can reopen the issue, and continue with improving this PR @amelchio
I wasn't sure why was it merged so quickly :)

@balloob
Copy link
Copy Markdown
Member

balloob commented Aug 1, 2019

My bad. I was doing a quick sweep through PRs prior to cutting the beta.

@yeralin
Copy link
Copy Markdown
Contributor Author

yeralin commented Aug 1, 2019

It's not critical. It certainly doesn't break things, so it is fine to keep it in there. But we do need to add more changes

@amelchio
Copy link
Copy Markdown
Contributor

amelchio commented Aug 2, 2019

Hmmm, as far as I can tell, this actually breaks the white support of Google Home for RGB and RGBW lights because it will now always use the second white LED which these products do not have. It also adds a color temperature slider that works poorly or not at all (again, AFAICT).

Thinking about it more, I suggest reverting this while working on the amendments.

amelchio added a commit to amelchio/home-assistant that referenced this pull request Aug 2, 2019
@amelchio amelchio mentioned this pull request Aug 2, 2019
4 tasks
@amelchio
Copy link
Copy Markdown
Contributor

amelchio commented Aug 2, 2019

I submitted a revert, also reverting some other bad changes that were recently made to flux_led :-/. Let's do further discussions in a new PR or in #23704 which I have now reopened.

pvizeli pushed a commit that referenced this pull request Aug 2, 2019
* Revert Black

* Revert "Introduce support for color temperature (#25503)"

This reverts commit e1d884a.

* Revert "Fix flux_led only-white controllers (#22210)"

This reverts commit 4813818.

* Revert "Fix MagicHome LEDs with flux_led component (#20733)"

This reverts commit 1444a68.

* Re-Black

* Use mode detection for scanned bulbs
@lock lock Bot locked and limited conversation to collaborators Aug 3, 2019
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.

Problems controlling Flux Led Smart Lights through Homeassistant

5 participants