Add type hints to LightEntity (#47024)
This commit is contained in:
parent
a243adc551
commit
215ab5fd40
4 changed files with 16 additions and 16 deletions
|
@ -88,8 +88,8 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
self._brightness: Optional[int] = None
|
||||
self._hs_color: Optional[Tuple[float, float]] = None
|
||||
self._color_temp: Optional[int] = None
|
||||
self._min_mireds: Optional[int] = 154
|
||||
self._max_mireds: Optional[int] = 500
|
||||
self._min_mireds: int = 154
|
||||
self._max_mireds: int = 500
|
||||
self._white_value: Optional[int] = None
|
||||
self._effect_list: Optional[List[str]] = None
|
||||
self._effect: Optional[str] = None
|
||||
|
@ -152,12 +152,12 @@ class LightGroup(GroupEntity, light.LightEntity):
|
|||
return self._color_temp
|
||||
|
||||
@property
|
||||
def min_mireds(self) -> Optional[int]:
|
||||
def min_mireds(self) -> int:
|
||||
"""Return the coldest color_temp that this light group supports."""
|
||||
return self._min_mireds
|
||||
|
||||
@property
|
||||
def max_mireds(self) -> Optional[int]:
|
||||
def max_mireds(self) -> int:
|
||||
"""Return the warmest color_temp that this light group supports."""
|
||||
return self._max_mireds
|
||||
|
||||
|
|
|
@ -407,46 +407,46 @@ class LightEntity(ToggleEntity):
|
|||
"""Representation of a light."""
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
def brightness(self) -> Optional[int]:
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def hs_color(self):
|
||||
def hs_color(self) -> Optional[Tuple[float, float]]:
|
||||
"""Return the hue and saturation color value [float, float]."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
def color_temp(self) -> Optional[int]:
|
||||
"""Return the CT color value in mireds."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def min_mireds(self):
|
||||
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
|
||||
|
||||
@property
|
||||
def max_mireds(self):
|
||||
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
|
||||
|
||||
@property
|
||||
def white_value(self):
|
||||
def white_value(self) -> Optional[int]:
|
||||
"""Return the white value of this light between 0..255."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def effect_list(self):
|
||||
def effect_list(self) -> Optional[List[str]]:
|
||||
"""Return the list of supported effects."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def effect(self):
|
||||
def effect(self) -> Optional[str]:
|
||||
"""Return the current effect."""
|
||||
return None
|
||||
|
||||
|
@ -495,7 +495,7 @@ class LightEntity(ToggleEntity):
|
|||
return {key: val for key, val in data.items() if val is not None}
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return 0
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||
return self._max_mireds
|
||||
|
||||
@property
|
||||
def supported_features(self) -> Optional[int]:
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return self._supported_features
|
||||
|
||||
|
|
|
@ -508,12 +508,12 @@ def _get_blue(temperature: float) -> float:
|
|||
return _bound(blue)
|
||||
|
||||
|
||||
def color_temperature_mired_to_kelvin(mired_temperature: float) -> float:
|
||||
def color_temperature_mired_to_kelvin(mired_temperature: float) -> int:
|
||||
"""Convert absolute mired shift to degrees kelvin."""
|
||||
return math.floor(1000000 / mired_temperature)
|
||||
|
||||
|
||||
def color_temperature_kelvin_to_mired(kelvin_temperature: float) -> float:
|
||||
def color_temperature_kelvin_to_mired(kelvin_temperature: float) -> int:
|
||||
"""Convert degrees kelvin to mired shift."""
|
||||
return math.floor(1000000 / kelvin_temperature)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue