mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Use ATTR_COLOR_TEMP_KELVIN in emulated_hue light (#132693)
This commit is contained in:
parent
fa9ee2adc6
commit
b1791aae63
@ -39,7 +39,7 @@ from homeassistant.components.http import KEY_HASS, HomeAssistantView
|
|||||||
from homeassistant.components.humidifier import ATTR_HUMIDITY, SERVICE_SET_HUMIDITY
|
from homeassistant.components.humidifier import ATTR_HUMIDITY, SERVICE_SET_HUMIDITY
|
||||||
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,
|
||||||
ATTR_XY_COLOR,
|
ATTR_XY_COLOR,
|
||||||
@ -67,6 +67,7 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import Event, EventStateChangedData, State
|
from homeassistant.core import Event, EventStateChangedData, State
|
||||||
from homeassistant.helpers.event import async_track_state_change_event
|
from homeassistant.helpers.event import async_track_state_change_event
|
||||||
|
from homeassistant.util import color as color_util
|
||||||
from homeassistant.util.json import json_loads
|
from homeassistant.util.json import json_loads
|
||||||
from homeassistant.util.network import is_local
|
from homeassistant.util.network import is_local
|
||||||
|
|
||||||
@ -500,7 +501,11 @@ class HueOneLightChangeView(HomeAssistantView):
|
|||||||
light.color_temp_supported(color_modes)
|
light.color_temp_supported(color_modes)
|
||||||
and parsed[STATE_COLOR_TEMP] is not None
|
and parsed[STATE_COLOR_TEMP] is not None
|
||||||
):
|
):
|
||||||
data[ATTR_COLOR_TEMP] = parsed[STATE_COLOR_TEMP]
|
data[ATTR_COLOR_TEMP_KELVIN] = (
|
||||||
|
color_util.color_temperature_mired_to_kelvin(
|
||||||
|
parsed[STATE_COLOR_TEMP]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
entity_features & LightEntityFeature.TRANSITION
|
entity_features & LightEntityFeature.TRANSITION
|
||||||
@ -702,7 +707,12 @@ def _build_entity_state_dict(entity: State) -> dict[str, Any]:
|
|||||||
else:
|
else:
|
||||||
data[STATE_HUE] = HUE_API_STATE_HUE_MIN
|
data[STATE_HUE] = HUE_API_STATE_HUE_MIN
|
||||||
data[STATE_SATURATION] = HUE_API_STATE_SAT_MIN
|
data[STATE_SATURATION] = HUE_API_STATE_SAT_MIN
|
||||||
data[STATE_COLOR_TEMP] = attributes.get(ATTR_COLOR_TEMP) or 0
|
kelvin = attributes.get(ATTR_COLOR_TEMP_KELVIN)
|
||||||
|
data[STATE_COLOR_TEMP] = (
|
||||||
|
color_util.color_temperature_kelvin_to_mired(kelvin)
|
||||||
|
if kelvin is not None
|
||||||
|
else 0
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data[STATE_BRIGHTNESS] = 0
|
data[STATE_BRIGHTNESS] = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user