From ebc7cf94c46de81374927b50e938a7fe206641e9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:38:12 +0000 Subject: [PATCH 1/2] Use ATTR_COLOR_TEMP_KELVIN in abode light --- homeassistant/components/abode/light.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/abode/light.py b/homeassistant/components/abode/light.py index d69aad80875e1..c220054610250 100644 --- a/homeassistant/components/abode/light.py +++ b/homeassistant/components/abode/light.py @@ -9,7 +9,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, - ATTR_COLOR_TEMP, + ATTR_COLOR_TEMP_KELVIN, ATTR_HS_COLOR, ColorMode, LightEntity, @@ -17,10 +17,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.util.color import ( - color_temperature_kelvin_to_mired, - color_temperature_mired_to_kelvin, -) +from homeassistant.util.color import color_temperature_kelvin_to_mired from . import AbodeSystem from .const import DOMAIN @@ -47,10 +44,8 @@ class AbodeLight(AbodeDevice, LightEntity): def turn_on(self, **kwargs: Any) -> None: """Turn on the light.""" - if ATTR_COLOR_TEMP in kwargs and self._device.is_color_capable: - self._device.set_color_temp( - int(color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])) - ) + if ATTR_COLOR_TEMP_KELVIN in kwargs and self._device.is_color_capable: + self._device.set_color_temp(kwargs[ATTR_COLOR_TEMP_KELVIN]) return if ATTR_HS_COLOR in kwargs and self._device.is_color_capable: From 07e7a970b1685f323e51cdb1e16c31ed3951ded0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:25:24 +0000 Subject: [PATCH 2/2] Improve --- homeassistant/components/abode/light.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/abode/light.py b/homeassistant/components/abode/light.py index c220054610250..9b21ee4eb7442 100644 --- a/homeassistant/components/abode/light.py +++ b/homeassistant/components/abode/light.py @@ -17,7 +17,6 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.util.color import color_temperature_kelvin_to_mired from . import AbodeSystem from .const import DOMAIN @@ -80,10 +79,10 @@ def brightness(self) -> int | None: return None @property - def color_temp(self) -> int | None: + def color_temp_kelvin(self) -> int | None: """Return the color temp of the light.""" if self._device.has_color: - return color_temperature_kelvin_to_mired(self._device.color_temp) + return int(self._device.color_temp) return None @property