-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Fix ESPHome color temperature precision for light entities #91424
Fix ESPHome color temperature precision for light entities #91424
Conversation
In components/esphome/light.py: - Add ADDR_COLOR_TEMP_KELVIN to list of parsed attributes - Import mired to kelvin conversion util code - If ATTR_COLOR_TEMP_KELVIN is set in service call, calculate target mired value in floating point. Fall back to ATTR_COLOR_TEMP if _KELVIN not available - Add {min,max}_color_temp_kelvin properties, computed from floating point mired,
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! |
Hey there @OttoWinter, @jesserockz, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
As a related sidenote, the documentation for the Home Assistant |
Finally figured out the remaining issue; I needed to override the There is one remaining issue, but it's out of scope of this PR: the function |
You could open another PR for this |
Check for color temp support before setting Kelvin color attributes Co-authored-by: J. Nick Koston <nick@koston.org>
I noticed the main implementation of mired_to_kelvin didn't have a zero division check so I didn't add one to
|
Since we don't know if it's the minimum or maximum value its effectively GIGO at this point and it's probably best to return the original value (0) so we don't have to figure out later where the data was mutated on us if there is a bug. |
#95029 will add some basic tests for this platform Won't be able to test today as I won't get home till tomorrow now as my original flight canceled and I have a few stops now |
Managed to pickup a different flight so might be able to test later but at worst I'll be able to test tomorrow. Still plenty of time to get this merged before beta on Wednesday |
One of the new tests will likely need to be adjusted for the behavior change sorry about the conflicts |
1 similar comment
One of the new tests will likely need to be adjusted for the behavior change sorry about the conflicts |
Unfortunately it looks like the functionality that automatically derives the min/max mireds from Kelvin around The only way I can think to get around this is to override the
IMO it's an inelegant solution, but until the base class implementation is fixed, we're going to still see off-by-one errors. |
Let's adjust the test here and get this merged (assuming testing is ok) Than the light class can be adjusted and we can rework this again |
Tested, everything looks good. |
I just realized the test is wrong since esphome sends the full float and the test doesn't. I'll fix the test and merge this |
Thanks @danielkent-net |
Proposed change
This PR changes the behavior of ESPHome
light
entities when setting color temperature. Currently, the color temperature can only be set in whole-number mireds, which cannot map to the full range of Kelvin color temperature values.Since ESPHome entities both transmit and store color temperature in floating point mireds, we can use this property to convert this value to and from Kelvin more accurately, and avoid many of the issues that result from rounding the value.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: