mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Migrate osramlightify lights to use Kelvin (#132688)
This commit is contained in:
parent
d2478b4058
commit
879e082b54
@ -11,7 +11,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
ATTR_HS_COLOR,
|
||||
ATTR_TRANSITION,
|
||||
@ -191,10 +191,7 @@ class Luminary(LightEntity):
|
||||
self._effect_list = []
|
||||
self._is_on = False
|
||||
self._available = True
|
||||
self._min_mireds = None
|
||||
self._max_mireds = None
|
||||
self._brightness = None
|
||||
self._color_temp = None
|
||||
self._rgb_color = None
|
||||
self._device_attributes = None
|
||||
|
||||
@ -256,11 +253,6 @@ class Luminary(LightEntity):
|
||||
"""Return last hs color value set."""
|
||||
return color_util.color_RGB_to_hs(*self._rgb_color)
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
"""Return the color temperature."""
|
||||
return self._color_temp
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""Return brightness of the luminary (0..255)."""
|
||||
@ -276,16 +268,6 @@ class Luminary(LightEntity):
|
||||
"""List of supported effects."""
|
||||
return self._effect_list
|
||||
|
||||
@property
|
||||
def min_mireds(self):
|
||||
"""Return the coldest color_temp that this light supports."""
|
||||
return self._min_mireds
|
||||
|
||||
@property
|
||||
def max_mireds(self):
|
||||
"""Return the warmest color_temp that this light supports."""
|
||||
return self._max_mireds
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique ID."""
|
||||
@ -326,12 +308,10 @@ class Luminary(LightEntity):
|
||||
self._rgb_color = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
|
||||
self._luminary.set_rgb(*self._rgb_color, transition)
|
||||
|
||||
if ATTR_COLOR_TEMP in kwargs:
|
||||
self._color_temp = kwargs[ATTR_COLOR_TEMP]
|
||||
self._luminary.set_temperature(
|
||||
int(color_util.color_temperature_mired_to_kelvin(self._color_temp)),
|
||||
transition,
|
||||
)
|
||||
if ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||
color_temp_kelvin = kwargs[ATTR_COLOR_TEMP_KELVIN]
|
||||
self._attr_color_temp_kelvin = color_temp_kelvin
|
||||
self._luminary.set_temperature(color_temp_kelvin, transition)
|
||||
|
||||
self._is_on = True
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
@ -362,10 +342,10 @@ class Luminary(LightEntity):
|
||||
self._attr_supported_features = self._get_supported_features()
|
||||
self._effect_list = self._get_effect_list()
|
||||
if ColorMode.COLOR_TEMP in self._attr_supported_color_modes:
|
||||
self._min_mireds = color_util.color_temperature_kelvin_to_mired(
|
||||
self._attr_max_color_temp_kelvin = (
|
||||
self._luminary.max_temp() or DEFAULT_KELVIN
|
||||
)
|
||||
self._max_mireds = color_util.color_temperature_kelvin_to_mired(
|
||||
self._attr_min_color_temp_kelvin = (
|
||||
self._luminary.min_temp() or DEFAULT_KELVIN
|
||||
)
|
||||
if len(self._attr_supported_color_modes) == 1:
|
||||
@ -380,9 +360,7 @@ class Luminary(LightEntity):
|
||||
self._brightness = int(self._luminary.lum() * 2.55)
|
||||
|
||||
if ColorMode.COLOR_TEMP in self._attr_supported_color_modes:
|
||||
self._color_temp = color_util.color_temperature_kelvin_to_mired(
|
||||
self._luminary.temp() or DEFAULT_KELVIN
|
||||
)
|
||||
self._attr_color_temp_kelvin = self._luminary.temp() or DEFAULT_KELVIN
|
||||
|
||||
if ColorMode.HS in self._attr_supported_color_modes:
|
||||
self._rgb_color = self._luminary.rgb()
|
||||
|
Loading…
x
Reference in New Issue
Block a user