mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Adjust type hints for LightEntityFeature (#82251)
This commit is contained in:
parent
8a084cf94d
commit
dd7bc7971f
@ -192,7 +192,7 @@ class Control4Light(Control4Entity, LightEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._is_dimmer:
|
if self._is_dimmer:
|
||||||
return LightEntityFeature.TRANSITION
|
return LightEntityFeature.TRANSITION
|
||||||
|
@ -112,7 +112,7 @@ class DecoraWifiLight(LightEntity):
|
|||||||
return {self.color_mode}
|
return {self.color_mode}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Return supported features."""
|
"""Return supported features."""
|
||||||
if self._switch.canSetLevel:
|
if self._switch.canSetLevel:
|
||||||
return LightEntityFeature.TRANSITION
|
return LightEntityFeature.TRANSITION
|
||||||
|
@ -347,9 +347,9 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
|
|||||||
return self._static_info.supported_color_modes_compat(self._api_version)
|
return self._static_info.supported_color_modes_compat(self._api_version)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
flags: int = LightEntityFeature.FLASH
|
flags = LightEntityFeature.FLASH
|
||||||
|
|
||||||
# All color modes except UNKNOWN,ON_OFF support transition
|
# All color modes except UNKNOWN,ON_OFF support transition
|
||||||
modes = self._native_supported_color_modes
|
modes = self._native_supported_color_modes
|
||||||
|
@ -82,9 +82,9 @@ class HMLight(HMDevice, LightEntity):
|
|||||||
return color_modes
|
return color_modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
features: int = LightEntityFeature.TRANSITION
|
features = LightEntityFeature.TRANSITION
|
||||||
if "PROGRAM" in self._hmdevice.WRITENODE:
|
if "PROGRAM" in self._hmdevice.WRITENODE:
|
||||||
features |= LightEntityFeature.EFFECT
|
features |= LightEntityFeature.EFFECT
|
||||||
return features
|
return features
|
||||||
|
@ -100,7 +100,7 @@ class HassAqualinkLight(AqualinkEntity, LightEntity):
|
|||||||
return {self.color_mode}
|
return {self.color_mode}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Return the list of features supported by the light."""
|
"""Return the list of features supported by the light."""
|
||||||
if self.dev.supports_effect:
|
if self.dev.supports_effect:
|
||||||
return LightEntityFeature.EFFECT
|
return LightEntityFeature.EFFECT
|
||||||
|
@ -793,7 +793,7 @@ class LightEntity(ToggleEntity):
|
|||||||
_attr_rgbw_color: tuple[int, 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_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] | set[str] | None = None
|
||||||
_attr_supported_features: int = 0
|
_attr_supported_features: LightEntityFeature | int = 0
|
||||||
_attr_xy_color: tuple[float, float] | None = None
|
_attr_xy_color: tuple[float, float] | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -1060,6 +1060,6 @@ class LightEntity(ToggleEntity):
|
|||||||
return self._attr_supported_color_modes
|
return self._attr_supported_color_modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
@ -101,7 +101,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity):
|
|||||||
|
|
||||||
return color_modes
|
return color_modes
|
||||||
|
|
||||||
def _determine_features(self):
|
def _determine_features(self) -> LightEntityFeature | int:
|
||||||
"""Get features supported by the device."""
|
"""Get features supported by the device."""
|
||||||
features = 0
|
features = 0
|
||||||
# Transition
|
# Transition
|
||||||
|
@ -254,7 +254,7 @@ class LightTemplate(TemplateEntity, LightEntity):
|
|||||||
return self._supported_color_modes
|
return self._supported_color_modes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = 0
|
||||||
if self._effect_script is not None:
|
if self._effect_script is not None:
|
||||||
|
@ -312,7 +312,7 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
|||||||
device: SmartLightStrip
|
device: SmartLightStrip
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return super().supported_features | LightEntityFeature.EFFECT
|
return super().supported_features | LightEntityFeature.EFFECT
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class UpbLight(UpbAttachedEntity, LightEntity):
|
|||||||
return {self.color_mode}
|
return {self.color_mode}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> LightEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._element.dimmable:
|
if self._element.dimmable:
|
||||||
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH
|
return LightEntityFeature.TRANSITION | LightEntityFeature.FLASH
|
||||||
|
@ -1520,7 +1520,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="supported_features",
|
function_name="supported_features",
|
||||||
return_type="int",
|
return_type=["LightEntityFeature", "int"],
|
||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="turn_on",
|
function_name="turn_on",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user