From 704457e975f39384af945a2c0270b330556df11c Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 6 Jan 2025 03:44:33 +0000 Subject: [PATCH] fix(light): replace ATTR_COLOR_TEMP with ATTR_COLOR_TEMP_KELVIN for X13 light device --- custom_components/midea_ac_lan/light.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/custom_components/midea_ac_lan/light.py b/custom_components/midea_ac_lan/light.py index 8e66cd2..b919d40 100644 --- a/custom_components/midea_ac_lan/light.py +++ b/custom_components/midea_ac_lan/light.py @@ -5,7 +5,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, - ATTR_COLOR_TEMP, + ATTR_COLOR_TEMP_KELVIN, ATTR_EFFECT, ColorMode, LightEntity, @@ -127,21 +127,12 @@ def color_temp(self) -> int | None: return None return round(1000000 / self.color_temp_kelvin) + # https://developers.home-assistant.io/blog/2024/12/14/kelvin-preferred-color-temperature-unit @property def color_temp_kelvin(self) -> int | None: """Midea Light color temperature kelvin.""" return cast("int", self._device.get_attribute(X13Attributes.color_temperature)) - @property - def min_mireds(self) -> int: - """Midea Light color temperature min mireds.""" - return round(1000000 / self.max_color_temp_kelvin) - - @property - def max_mireds(self) -> int: - """Midea Light color temperature max mireds.""" - return round(1000000 / self.min_color_temp_kelvin) - @property def min_color_temp_kelvin(self) -> int: """Midea Light min color temperature kelvin.""" @@ -169,7 +160,7 @@ def turn_on(self, **kwargs: Any) -> None: # noqa: ANN401 for key, value in kwargs.items(): if key == ATTR_BRIGHTNESS: self._device.set_attribute(attr=X13Attributes.brightness, value=value) - if key == ATTR_COLOR_TEMP: + if key == ATTR_COLOR_TEMP_KELVIN: self._device.set_attribute( attr=X13Attributes.color_temperature, value=round(1000000 / value),