mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Migrate wemo lights to use Kelvin (#132808)
This commit is contained in:
parent
e31e4c5d75
commit
bd6df06248
@ -8,7 +8,7 @@ from pywemo import Bridge, BridgeLight, Dimmer
|
|||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP_KELVIN,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
ColorMode,
|
ColorMode,
|
||||||
@ -123,9 +123,11 @@ class WemoLight(WemoEntity, LightEntity):
|
|||||||
return self.light.state.get("color_xy")
|
return self.light.state.get("color_xy")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self) -> int | None:
|
def color_temp_kelvin(self) -> int | None:
|
||||||
"""Return the color temperature of this light in mireds."""
|
"""Return the color temperature value in Kelvin."""
|
||||||
return self.light.state.get("temperature_mireds")
|
if not (mireds := self.light.state.get("temperature_mireds")):
|
||||||
|
return None
|
||||||
|
return color_util.color_temperature_mired_to_kelvin(mireds)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> ColorMode:
|
def color_mode(self) -> ColorMode:
|
||||||
@ -165,7 +167,7 @@ class WemoLight(WemoEntity, LightEntity):
|
|||||||
xy_color = None
|
xy_color = None
|
||||||
|
|
||||||
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness or 255)
|
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness or 255)
|
||||||
color_temp = kwargs.get(ATTR_COLOR_TEMP)
|
color_temp_kelvin = kwargs.get(ATTR_COLOR_TEMP_KELVIN)
|
||||||
hs_color = kwargs.get(ATTR_HS_COLOR)
|
hs_color = kwargs.get(ATTR_HS_COLOR)
|
||||||
transition_time = int(kwargs.get(ATTR_TRANSITION, 0))
|
transition_time = int(kwargs.get(ATTR_TRANSITION, 0))
|
||||||
|
|
||||||
@ -182,9 +184,9 @@ class WemoLight(WemoEntity, LightEntity):
|
|||||||
if xy_color is not None:
|
if xy_color is not None:
|
||||||
self.light.set_color(xy_color, transition=transition_time)
|
self.light.set_color(xy_color, transition=transition_time)
|
||||||
|
|
||||||
if color_temp is not None:
|
if color_temp_kelvin is not None:
|
||||||
self.light.set_temperature(
|
self.light.set_temperature(
|
||||||
mireds=color_temp, transition=transition_time
|
kelvin=color_temp_kelvin, transition=transition_time
|
||||||
)
|
)
|
||||||
|
|
||||||
self.light.turn_on(**turn_on_kwargs)
|
self.light.turn_on(**turn_on_kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user