Define light entity attributes as class variables (#50941)

pull/50965/head
Franck Nijhof 2021-05-22 18:21:31 +02:00 committed by GitHub
parent d3bc2bc47f
commit cad4ec867b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 14 deletions

View File

@ -559,15 +559,30 @@ class Profiles:
class LightEntity(ToggleEntity):
"""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
def brightness(self) -> int | None:
"""Return the brightness of this light between 0..255."""
return None
return self._attr_brightness
@property
def color_mode(self) -> str | None:
"""Return the color mode of the light."""
return None
return self._attr_color_mode
@property
def _light_internal_color_mode(self) -> str:
@ -600,22 +615,22 @@ class LightEntity(ToggleEntity):
@property
def hs_color(self) -> tuple[float, float] | None:
"""Return the hue and saturation color value [float, float]."""
return None
return self._attr_hs_color
@property
def xy_color(self) -> tuple[float, float] | None:
"""Return the xy color value [float, float]."""
return None
return self._attr_xy_color
@property
def rgb_color(self) -> tuple[int, int, int] | None:
"""Return the rgb color value [int, int, int]."""
return None
return self._attr_rgb_color
@property
def rgbw_color(self) -> tuple[int, int, int, int] | None:
"""Return the rgbw color value [int, int, int, int]."""
return None
return self._attr_rgbw_color
@property
def _light_internal_rgbw_color(self) -> tuple[int, int, int, int] | None:
@ -639,26 +654,26 @@ class LightEntity(ToggleEntity):
@property
def rgbww_color(self) -> tuple[int, int, int, int, int] | None:
"""Return the rgbww color value [int, int, int, int, int]."""
return None
return self._attr_rgbww_color
@property
def color_temp(self) -> int | None:
"""Return the CT color value in mireds."""
return None
return self._attr_color_temp
@property
def min_mireds(self) -> int:
"""Return the coldest color_temp that this light supports."""
# Default to the Philips Hue value that HA has always assumed
# https://developers.meethue.com/documentation/core-concepts
return 153
return self._attr_min_mired
@property
def max_mireds(self) -> int:
"""Return the warmest color_temp that this light supports."""
# Default to the Philips Hue value that HA has always assumed
# https://developers.meethue.com/documentation/core-concepts
return 500
return self._attr_max_mired
@property
def white_value(self) -> int | None:
@ -668,12 +683,12 @@ class LightEntity(ToggleEntity):
@property
def effect_list(self) -> list[str] | None:
"""Return the list of supported effects."""
return None
return self._attr_effect_list
@property
def effect(self) -> str | None:
"""Return the current effect."""
return None
return self._attr_effect
@property
def capability_attributes(self):
@ -808,12 +823,12 @@ class LightEntity(ToggleEntity):
@property
def supported_color_modes(self) -> set | None:
"""Flag supported color modes."""
return None
return self._attr_supported_color_modes
@property
def supported_features(self) -> int:
"""Flag supported features."""
return 0
return self._attr_supported_features
class Light(LightEntity):