mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix colortemp conversion for lifx lights (#6087)
This commit is contained in:
parent
86a1b0a6c6
commit
75df4be733
@ -14,6 +14,8 @@ from homeassistant.components.light import (
|
|||||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
|
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
|
||||||
SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
|
SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
|
||||||
from homeassistant.helpers.event import track_time_change
|
from homeassistant.helpers.event import track_time_change
|
||||||
|
from homeassistant.util.color import (
|
||||||
|
color_temperature_mired_to_kelvin, color_temperature_kelvin_to_mired)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -181,8 +183,7 @@ class LIFXLight(Light):
|
|||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the color temperature."""
|
"""Return the color temperature."""
|
||||||
temperature = int(TEMP_MIN_HASS + (TEMP_MAX_HASS - TEMP_MIN_HASS) *
|
temperature = color_temperature_kelvin_to_mired(self._kel)
|
||||||
(self._kel - TEMP_MIN) / (TEMP_MAX - TEMP_MIN))
|
|
||||||
|
|
||||||
_LOGGER.debug("color_temp: %d", temperature)
|
_LOGGER.debug("color_temp: %d", temperature)
|
||||||
return temperature
|
return temperature
|
||||||
@ -219,11 +220,8 @@ class LIFXLight(Light):
|
|||||||
brightness = self._bri
|
brightness = self._bri
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
# pylint: disable=fixme
|
kelvin = int(color_temperature_mired_to_kelvin(
|
||||||
# TODO: Use color_temperature_mired_to_kelvin from util.color
|
kwargs[ATTR_COLOR_TEMP]))
|
||||||
kelvin = int(((TEMP_MAX - TEMP_MIN) *
|
|
||||||
(kwargs[ATTR_COLOR_TEMP] - TEMP_MIN_HASS) /
|
|
||||||
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
|
|
||||||
else:
|
else:
|
||||||
kelvin = self._kel
|
kelvin = self._kel
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user