From f92949d72630bf9a8b5b1e1bdfbbc31b7f9f3fb3 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:01:41 +0000 Subject: [PATCH 1/2] Use ATTR_COLOR_TEMP_KELVIN in smartthings light --- homeassistant/components/smartthings/light.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/smartthings/light.py b/homeassistant/components/smartthings/light.py index fd4b87f0ee786..f77db140b27cf 100644 --- a/homeassistant/components/smartthings/light.py +++ b/homeassistant/components/smartthings/light.py @@ -10,7 +10,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, - ATTR_COLOR_TEMP, + ATTR_COLOR_TEMP_KELVIN, ATTR_HS_COLOR, ATTR_TRANSITION, ColorMode, @@ -122,8 +122,8 @@ async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" tasks = [] # Color temperature - if ATTR_COLOR_TEMP in kwargs: - tasks.append(self.async_set_color_temp(kwargs[ATTR_COLOR_TEMP])) + if ATTR_COLOR_TEMP_KELVIN in kwargs: + tasks.append(self.async_set_color_temp(kwargs[ATTR_COLOR_TEMP_KELVIN])) # Color if ATTR_HS_COLOR in kwargs: tasks.append(self.async_set_color(kwargs[ATTR_HS_COLOR])) @@ -181,10 +181,9 @@ async def async_set_color(self, hs_color): saturation = max(min(float(hs_color[1]), 100.0), 0.0) await self._device.set_color(hue, saturation, set_status=True) - async def async_set_color_temp(self, value: float): + async def async_set_color_temp(self, value: int): """Set the color temperature of the device.""" - kelvin = color_util.color_temperature_mired_to_kelvin(value) - kelvin = max(min(kelvin, 30000), 1) + kelvin = max(min(value, 30000), 1) await self._device.set_color_temperature(kelvin, set_status=True) async def async_set_level(self, brightness: int, transition: int): From 8a047f7d82891f7fdc59f3a27d3eaccf1fafb35a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:45:34 +0000 Subject: [PATCH 2/2] Adjust --- homeassistant/components/smartthings/light.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/smartthings/light.py b/homeassistant/components/smartthings/light.py index f77db140b27cf..eb7c9af246bd9 100644 --- a/homeassistant/components/smartthings/light.py +++ b/homeassistant/components/smartthings/light.py @@ -21,7 +21,6 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -import homeassistant.util.color as color_util from .const import DATA_BROKERS, DOMAIN from .entity import SmartThingsEntity @@ -79,12 +78,12 @@ class SmartThingsLight(SmartThingsEntity, LightEntity): # SmartThings does not expose this attribute, instead it's # implemented within each device-type handler. This value is the # lowest kelvin found supported across 20+ handlers. - _attr_max_mireds = 500 # 2000K + _attr_min_color_temp_kelvin = 2000 # 500 mireds # SmartThings does not expose this attribute, instead it's # implemented within each device-type handler. This value is the # highest kelvin found supported across 20+ handlers. - _attr_min_mireds = 111 # 9000K + _attr_max_color_temp_kelvin = 9000 # 111 mireds def __init__(self, device): """Initialize a SmartThingsLight.""" @@ -164,9 +163,7 @@ async def async_update(self) -> None: ) # Color Temperature if ColorMode.COLOR_TEMP in self._attr_supported_color_modes: - self._attr_color_temp = color_util.color_temperature_kelvin_to_mired( - self._device.status.color_temperature - ) + self._attr_color_temp_kelvin = self._device.status.color_temperature # Color if ColorMode.HS in self._attr_supported_color_modes: self._attr_hs_color = (