mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +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 (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP_KELVIN,
|
||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
@ -191,10 +191,7 @@ class Luminary(LightEntity):
|
|||||||
self._effect_list = []
|
self._effect_list = []
|
||||||
self._is_on = False
|
self._is_on = False
|
||||||
self._available = True
|
self._available = True
|
||||||
self._min_mireds = None
|
|
||||||
self._max_mireds = None
|
|
||||||
self._brightness = None
|
self._brightness = None
|
||||||
self._color_temp = None
|
|
||||||
self._rgb_color = None
|
self._rgb_color = None
|
||||||
self._device_attributes = None
|
self._device_attributes = None
|
||||||
|
|
||||||
@ -256,11 +253,6 @@ class Luminary(LightEntity):
|
|||||||
"""Return last hs color value set."""
|
"""Return last hs color value set."""
|
||||||
return color_util.color_RGB_to_hs(*self._rgb_color)
|
return color_util.color_RGB_to_hs(*self._rgb_color)
|
||||||
|
|
||||||
@property
|
|
||||||
def color_temp(self):
|
|
||||||
"""Return the color temperature."""
|
|
||||||
return self._color_temp
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return brightness of the luminary (0..255)."""
|
"""Return brightness of the luminary (0..255)."""
|
||||||
@ -276,16 +268,6 @@ class Luminary(LightEntity):
|
|||||||
"""List of supported effects."""
|
"""List of supported effects."""
|
||||||
return self._effect_list
|
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
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID."""
|
"""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._rgb_color = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
|
||||||
self._luminary.set_rgb(*self._rgb_color, transition)
|
self._luminary.set_rgb(*self._rgb_color, transition)
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||||
self._color_temp = kwargs[ATTR_COLOR_TEMP]
|
color_temp_kelvin = kwargs[ATTR_COLOR_TEMP_KELVIN]
|
||||||
self._luminary.set_temperature(
|
self._attr_color_temp_kelvin = color_temp_kelvin
|
||||||
int(color_util.color_temperature_mired_to_kelvin(self._color_temp)),
|
self._luminary.set_temperature(color_temp_kelvin, transition)
|
||||||
transition,
|
|
||||||
)
|
|
||||||
|
|
||||||
self._is_on = True
|
self._is_on = True
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
@ -362,10 +342,10 @@ class Luminary(LightEntity):
|
|||||||
self._attr_supported_features = self._get_supported_features()
|
self._attr_supported_features = self._get_supported_features()
|
||||||
self._effect_list = self._get_effect_list()
|
self._effect_list = self._get_effect_list()
|
||||||
if ColorMode.COLOR_TEMP in self._attr_supported_color_modes:
|
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._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
|
self._luminary.min_temp() or DEFAULT_KELVIN
|
||||||
)
|
)
|
||||||
if len(self._attr_supported_color_modes) == 1:
|
if len(self._attr_supported_color_modes) == 1:
|
||||||
@ -380,9 +360,7 @@ class Luminary(LightEntity):
|
|||||||
self._brightness = int(self._luminary.lum() * 2.55)
|
self._brightness = int(self._luminary.lum() * 2.55)
|
||||||
|
|
||||||
if ColorMode.COLOR_TEMP in self._attr_supported_color_modes:
|
if ColorMode.COLOR_TEMP in self._attr_supported_color_modes:
|
||||||
self._color_temp = color_util.color_temperature_kelvin_to_mired(
|
self._attr_color_temp_kelvin = self._luminary.temp() or DEFAULT_KELVIN
|
||||||
self._luminary.temp() or DEFAULT_KELVIN
|
|
||||||
)
|
|
||||||
|
|
||||||
if ColorMode.HS in self._attr_supported_color_modes:
|
if ColorMode.HS in self._attr_supported_color_modes:
|
||||||
self._rgb_color = self._luminary.rgb()
|
self._rgb_color = self._luminary.rgb()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user