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
38 changes: 26 additions & 12 deletions homeassistant/components/tasmota/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from homeassistant.components import light
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_TRANSITION,
Expand All @@ -32,6 +32,7 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import color as color_util

from .const import DATA_REMOVE_DISCOVER_COMPONENT
from .discovery import TASMOTA_DISCOVERY_ENTITY_NEW
Expand Down Expand Up @@ -199,19 +200,27 @@ def color_mode(self) -> str | None:
return self._color_mode

@property
def color_temp(self) -> int | None:
"""Return the color temperature in mired."""
return self._color_temp
def color_temp_kelvin(self) -> int | None:
"""Return the color temperature value in Kelvin."""
return (
color_util.color_temperature_mired_to_kelvin(self._color_temp)
if self._color_temp
else None
)

@property
def min_mireds(self) -> int:
"""Return the coldest color_temp that this light supports."""
return self._tasmota_entity.min_mireds
def max_color_temp_kelvin(self) -> int:
"""Return the coldest color_temp_kelvin that this light supports."""
return color_util.color_temperature_mired_to_kelvin(
self._tasmota_entity.min_mireds
)

@property
def max_mireds(self) -> int:
"""Return the warmest color_temp that this light supports."""
return self._tasmota_entity.max_mireds
def min_color_temp_kelvin(self) -> int:
"""Return the warmest color_temp_kelvin that this light supports."""
return color_util.color_temperature_mired_to_kelvin(
self._tasmota_entity.max_mireds
)

@property
def effect(self) -> str | None:
Expand Down Expand Up @@ -255,8 +264,13 @@ async def async_turn_on(self, **kwargs: Any) -> None:
if ATTR_BRIGHTNESS in kwargs and brightness_supported(supported_color_modes):
attributes["brightness"] = scale_brightness(kwargs[ATTR_BRIGHTNESS])

if ATTR_COLOR_TEMP in kwargs and ColorMode.COLOR_TEMP in supported_color_modes:
attributes["color_temp"] = int(kwargs[ATTR_COLOR_TEMP])
if (
ATTR_COLOR_TEMP_KELVIN in kwargs
and ColorMode.COLOR_TEMP in supported_color_modes
):
attributes["color_temp"] = color_util.color_temperature_kelvin_to_mired(
kwargs[ATTR_COLOR_TEMP_KELVIN]
)

if ATTR_EFFECT in kwargs:
attributes["effect"] = kwargs[ATTR_EFFECT]
Expand Down