Skip to content

Commit

Permalink
fix(light): replace ATTR_COLOR_TEMP with ATTR_COLOR_TEMP_KELVIN for X…
Browse files Browse the repository at this point in the history
…13 light device
  • Loading branch information
wuwentao committed Jan 6, 2025
1 parent da2ec74 commit 704457e
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions custom_components/midea_ac_lan/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ColorMode,
LightEntity,
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 704457e

Please sign in to comment.