mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Define light entity attributes as class variables (#50941)
This commit is contained in:
parent
d3bc2bc47f
commit
cad4ec867b
@ -559,15 +559,30 @@ class Profiles:
|
|||||||
class LightEntity(ToggleEntity):
|
class LightEntity(ToggleEntity):
|
||||||
"""Base class for light entities."""
|
"""Base class for light entities."""
|
||||||
|
|
||||||
|
_attr_brightness: int | None = None
|
||||||
|
_attr_color_mode: str | None = None
|
||||||
|
_attr_color_temp: int | None = None
|
||||||
|
_attr_effect_list: list[str] | None = None
|
||||||
|
_attr_effect: str | None = None
|
||||||
|
_attr_hs_color: tuple[float, float] | None = None
|
||||||
|
_attr_max_mired: int = 500
|
||||||
|
_attr_min_mired: int = 153
|
||||||
|
_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 | None = None
|
||||||
|
_attr_supported_features: int = 0
|
||||||
|
_attr_xy_color: tuple[float, float] | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int | None:
|
def brightness(self) -> int | None:
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
return None
|
return self._attr_brightness
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_mode(self) -> str | None:
|
def color_mode(self) -> str | None:
|
||||||
"""Return the color mode of the light."""
|
"""Return the color mode of the light."""
|
||||||
return None
|
return self._attr_color_mode
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _light_internal_color_mode(self) -> str:
|
def _light_internal_color_mode(self) -> str:
|
||||||
@ -600,22 +615,22 @@ class LightEntity(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def hs_color(self) -> tuple[float, float] | None:
|
def hs_color(self) -> tuple[float, float] | None:
|
||||||
"""Return the hue and saturation color value [float, float]."""
|
"""Return the hue and saturation color value [float, float]."""
|
||||||
return None
|
return self._attr_hs_color
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def xy_color(self) -> tuple[float, float] | None:
|
def xy_color(self) -> tuple[float, float] | None:
|
||||||
"""Return the xy color value [float, float]."""
|
"""Return the xy color value [float, float]."""
|
||||||
return None
|
return self._attr_xy_color
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rgb_color(self) -> tuple[int, int, int] | None:
|
def rgb_color(self) -> tuple[int, int, int] | None:
|
||||||
"""Return the rgb color value [int, int, int]."""
|
"""Return the rgb color value [int, int, int]."""
|
||||||
return None
|
return self._attr_rgb_color
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rgbw_color(self) -> tuple[int, int, int, int] | None:
|
def rgbw_color(self) -> tuple[int, int, int, int] | None:
|
||||||
"""Return the rgbw color value [int, int, int, int]."""
|
"""Return the rgbw color value [int, int, int, int]."""
|
||||||
return None
|
return self._attr_rgbw_color
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _light_internal_rgbw_color(self) -> tuple[int, int, int, int] | None:
|
def _light_internal_rgbw_color(self) -> tuple[int, int, int, int] | None:
|
||||||
@ -639,26 +654,26 @@ class LightEntity(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
|
def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
|
||||||
"""Return the rgbww color value [int, int, int, int, int]."""
|
"""Return the rgbww color value [int, int, int, int, int]."""
|
||||||
return None
|
return self._attr_rgbww_color
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self) -> int | None:
|
def color_temp(self) -> int | None:
|
||||||
"""Return the CT color value in mireds."""
|
"""Return the CT color value in mireds."""
|
||||||
return None
|
return self._attr_color_temp
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_mireds(self) -> int:
|
def min_mireds(self) -> int:
|
||||||
"""Return the coldest color_temp that this light supports."""
|
"""Return the coldest color_temp that this light supports."""
|
||||||
# Default to the Philips Hue value that HA has always assumed
|
# Default to the Philips Hue value that HA has always assumed
|
||||||
# https://developers.meethue.com/documentation/core-concepts
|
# https://developers.meethue.com/documentation/core-concepts
|
||||||
return 153
|
return self._attr_min_mired
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_mireds(self) -> int:
|
def max_mireds(self) -> int:
|
||||||
"""Return the warmest color_temp that this light supports."""
|
"""Return the warmest color_temp that this light supports."""
|
||||||
# Default to the Philips Hue value that HA has always assumed
|
# Default to the Philips Hue value that HA has always assumed
|
||||||
# https://developers.meethue.com/documentation/core-concepts
|
# https://developers.meethue.com/documentation/core-concepts
|
||||||
return 500
|
return self._attr_max_mired
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def white_value(self) -> int | None:
|
def white_value(self) -> int | None:
|
||||||
@ -668,12 +683,12 @@ class LightEntity(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def effect_list(self) -> list[str] | None:
|
def effect_list(self) -> list[str] | None:
|
||||||
"""Return the list of supported effects."""
|
"""Return the list of supported effects."""
|
||||||
return None
|
return self._attr_effect_list
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def effect(self) -> str | None:
|
def effect(self) -> str | None:
|
||||||
"""Return the current effect."""
|
"""Return the current effect."""
|
||||||
return None
|
return self._attr_effect
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def capability_attributes(self):
|
def capability_attributes(self):
|
||||||
@ -808,12 +823,12 @@ class LightEntity(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def supported_color_modes(self) -> set | None:
|
def supported_color_modes(self) -> set | None:
|
||||||
"""Flag supported color modes."""
|
"""Flag supported color modes."""
|
||||||
return None
|
return self._attr_supported_color_modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return 0
|
return self._attr_supported_features
|
||||||
|
|
||||||
|
|
||||||
class Light(LightEntity):
|
class Light(LightEntity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user