Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions homeassistant/components/deconz/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_FLASH,
ATTR_HS_COLOR,
Expand All @@ -30,7 +30,11 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.color import color_hs_to_xy
from homeassistant.util.color import (
color_hs_to_xy,
color_temperature_kelvin_to_mired,
color_temperature_mired_to_kelvin,
)

from .const import DOMAIN as DECONZ_DOMAIN, POWER_PLUGS
from .entity import DeconzDevice
Expand Down Expand Up @@ -256,9 +260,11 @@ def brightness(self) -> int | None:
return self._device.brightness

@property
def color_temp(self) -> int | None:
def color_temp_kelvin(self) -> int | None:
"""Return the CT color value."""
return self._device.color_temp
if self._device.color_temp is None:
return None
return color_temperature_mired_to_kelvin(self._device.color_temp)

@property
def hs_color(self) -> tuple[float, float] | None:
Expand All @@ -284,8 +290,10 @@ async def async_turn_on(self, **kwargs: Any) -> None:
if ATTR_BRIGHTNESS in kwargs:
data["brightness"] = kwargs[ATTR_BRIGHTNESS]

if ATTR_COLOR_TEMP in kwargs:
data["color_temperature"] = kwargs[ATTR_COLOR_TEMP]
if ATTR_COLOR_TEMP_KELVIN in kwargs:
data["color_temperature"] = color_temperature_kelvin_to_mired(
kwargs[ATTR_COLOR_TEMP_KELVIN]
)

if ATTR_HS_COLOR in kwargs:
if ColorMode.XY in self._attr_supported_color_modes:
Expand Down Expand Up @@ -338,14 +346,18 @@ class DeconzLight(DeconzBaseLight[Light]):
"""Representation of a deCONZ light."""

@property
def max_mireds(self) -> int:
"""Return the warmest color_temp that this light supports."""
return self._device.max_color_temp or super().max_mireds
def min_color_temp_kelvin(self) -> int:
"""Return the warmest color_temp_kelvin that this light supports."""
if max_color_temp_mireds := self._device.max_color_temp:
return color_temperature_mired_to_kelvin(max_color_temp_mireds)
return super().min_color_temp_kelvin

@property
def min_mireds(self) -> int:
"""Return the coldest color_temp that this light supports."""
return self._device.min_color_temp or super().min_mireds
def max_color_temp_kelvin(self) -> int:
"""Return the coldest color_temp_kelvin that this light supports."""
if min_color_temp_mireds := self._device.min_color_temp:
return color_temperature_mired_to_kelvin(min_color_temp_mireds)
return super().max_color_temp_kelvin

@callback
def async_update_callback(self) -> None:
Expand Down