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

Use kelvins as the preferred white temperature unit #146

Open
amelchio opened this Issue Feb 10, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@amelchio
Copy link
Member

amelchio commented Feb 10, 2019

Home Assistant currently uses mireds as the internal representation of color temperature for white lights. I believe this has no particular reasoning other than the Hue API being the first one implemented and it uses mireds.

However, lights are always advertised with a certain kelvin range, even Hue bulbs, so this is the scale that humans know and also the one used for most other light APIs.

This means that almost all light integrations must do kelvin/mired conversions and that has resulted in numerous bugs. We have had bugs such as swapped warm/cold, division by zero and setting a temperature that is slightly (but noticeably) wrong. These kinds of bugs continue to appear in new implementations. This is because implementors expect kelvins and mireds to be related by a linear function but they are not.

Since the kelvin/mired relationship is reciprocal rather than linear, an interesting artifact is that the color temperature slider in the UI is not intuitive. For a 2000K-8000K (500-125 mireds) bulb, the expected midpoint is 5000K but the midpoint we currently use in the UI is way off at 3200K.

Proposal

  • We currently have ATTR_KELVIN as an alternative way to provide ATTR_COLOR_TEMP. I propose to reverse this relationship, making ATTR_KELVIN the primary attribute that platforms receive.
  • Introduce a kelvin property for the color temperature of a light. If needed, we can keep color_temp centrally, just like hs_color auto-converts to rgb_color.
  • Attributes min_mireds/max_mireds become min_kelvin/max_kelvin or maybe today we have a better way to provide these values to the frontend?
  • Rename SUPPORT_COLOR_TEMP to SUPPORT_KELVIN
  • Change the UI to use a kelvin scale.

If we can agree, I volunteer to implement these changes across all light platforms. It is not entirely clear to me how it would affect external stuff like mqtt?

@OttoWinter

This comment has been minimized.

Copy link
Member

OttoWinter commented Feb 10, 2019

I 100% agree with this. The internal use of mired has always annoyed me very much (without HA I probably wouldn't even have had to learn what that scale is)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment