Skip to content

Commit

Permalink
Use ATTR_COLOR_TEMP_KELVIN in emulated_hue light (home-assistant#132693)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Dec 9, 2024
1 parent fa9ee2a commit b1791aa
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions homeassistant/components/emulated_hue/hue_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from homeassistant.components.humidifier import ATTR_HUMIDITY, SERVICE_SET_HUMIDITY
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_HS_COLOR,
ATTR_TRANSITION,
ATTR_XY_COLOR,
Expand Down Expand Up @@ -67,6 +67,7 @@
)
from homeassistant.core import Event, EventStateChangedData, State
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.network import is_local

Expand Down Expand Up @@ -500,7 +501,11 @@ async def put( # noqa: C901
light.color_temp_supported(color_modes)
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 (
entity_features & LightEntityFeature.TRANSITION
Expand Down Expand Up @@ -702,7 +707,12 @@ def _build_entity_state_dict(entity: State) -> dict[str, Any]:
else:
data[STATE_HUE] = HUE_API_STATE_HUE_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:
data[STATE_BRIGHTNESS] = 0
Expand Down

0 comments on commit b1791aa

Please sign in to comment.