mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Remove str from light color mode (#161755)
This commit is contained in:
@@ -300,7 +300,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
|
||||
|
||||
@property
|
||||
@esphome_state_property
|
||||
def color_mode(self) -> str:
|
||||
def color_mode(self) -> ColorMode:
|
||||
"""Return the color mode of the light."""
|
||||
if not self._supports_color_mode:
|
||||
supported_color_modes = self.supported_color_modes
|
||||
|
||||
@@ -123,8 +123,8 @@ def filter_supported_color_modes(color_modes: Iterable[ColorMode]) -> set[ColorM
|
||||
|
||||
|
||||
def valid_supported_color_modes(
|
||||
color_modes: Iterable[ColorMode | str],
|
||||
) -> set[ColorMode | str]:
|
||||
color_modes: Iterable[ColorMode],
|
||||
) -> set[ColorMode]:
|
||||
"""Validate the given color modes."""
|
||||
color_modes = set(color_modes)
|
||||
if (
|
||||
@@ -902,7 +902,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
|
||||
entity_description: LightEntityDescription
|
||||
_attr_brightness: int | None = None
|
||||
_attr_color_mode: ColorMode | str | None = None
|
||||
_attr_color_mode: ColorMode | None = None
|
||||
_attr_color_temp_kelvin: int | None = None
|
||||
_attr_effect_list: list[str] | None = None
|
||||
_attr_effect: str | None = None
|
||||
@@ -915,7 +915,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
_attr_rgb_color: tuple[int, int, int] | None = None
|
||||
_attr_rgbw_color: tuple[int, int, int, int] | None = None
|
||||
_attr_rgbww_color: tuple[int, int, int, int, int] | None = None
|
||||
_attr_supported_color_modes: set[ColorMode] | set[str] | None = None
|
||||
_attr_supported_color_modes: set[ColorMode] | None = None
|
||||
_attr_supported_features: LightEntityFeature = LightEntityFeature(0)
|
||||
_attr_xy_color: tuple[float, float] | None = None
|
||||
|
||||
@@ -932,7 +932,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
return self._attr_brightness
|
||||
|
||||
@cached_property
|
||||
def color_mode(self) -> ColorMode | str | None:
|
||||
def color_mode(self) -> ColorMode | None:
|
||||
"""Return the color mode of the light."""
|
||||
return self._attr_color_mode
|
||||
|
||||
@@ -1233,7 +1233,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
|
||||
def __validate_supported_color_modes(
|
||||
self,
|
||||
supported_color_modes: set[ColorMode] | set[str],
|
||||
supported_color_modes: set[ColorMode],
|
||||
) -> None:
|
||||
"""Validate the supported color modes."""
|
||||
if self.__color_mode_reported:
|
||||
@@ -1339,7 +1339,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
return data
|
||||
|
||||
@property
|
||||
def _light_internal_supported_color_modes(self) -> set[ColorMode] | set[str]:
|
||||
def _light_internal_supported_color_modes(self) -> set[ColorMode]:
|
||||
"""Calculate supported color modes with backwards compatibility."""
|
||||
if (_supported_color_modes := self.supported_color_modes) is not None:
|
||||
self.__validate_supported_color_modes(_supported_color_modes)
|
||||
@@ -1379,7 +1379,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
return supported_color_modes
|
||||
|
||||
@cached_property
|
||||
def supported_color_modes(self) -> set[ColorMode] | set[str] | None:
|
||||
def supported_color_modes(self) -> set[ColorMode] | None:
|
||||
"""Flag supported color modes."""
|
||||
return self._attr_supported_color_modes
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ class LimitlessLEDGroup(LightEntity, RestoreEntity):
|
||||
return self._attr_brightness
|
||||
|
||||
@property
|
||||
def color_mode(self) -> str | None:
|
||||
def color_mode(self) -> ColorMode:
|
||||
"""Return the color mode of the light."""
|
||||
if self._fixed_color_mode:
|
||||
return self._fixed_color_mode
|
||||
|
||||
@@ -1829,7 +1829,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="color_mode",
|
||||
return_type=["ColorMode", "str", None],
|
||||
return_type=["ColorMode", None],
|
||||
mandatory=True,
|
||||
),
|
||||
TypeHintMatch(
|
||||
@@ -1884,7 +1884,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
||||
),
|
||||
TypeHintMatch(
|
||||
function_name="supported_color_modes",
|
||||
return_type=["set[ColorMode]", "set[str]", None],
|
||||
return_type=["set[ColorMode]", None],
|
||||
mandatory=True,
|
||||
),
|
||||
TypeHintMatch(
|
||||
|
||||
Reference in New Issue
Block a user