mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Adjust type hints for CoverEntityFeature (#82238)
This commit is contained in:
parent
6856374f24
commit
17573196c8
@ -70,7 +70,7 @@ class AcmedaCover(AcmedaBase, CoverEntity):
|
|||||||
return position
|
return position
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = 0
|
||||||
if self.current_cover_position is not None:
|
if self.current_cover_position is not None:
|
||||||
|
@ -232,6 +232,7 @@ class CoverEntity(Entity):
|
|||||||
_attr_is_closing: bool | None = None
|
_attr_is_closing: bool | None = None
|
||||||
_attr_is_opening: bool | None = None
|
_attr_is_opening: bool | None = None
|
||||||
_attr_state: None = None
|
_attr_state: None = None
|
||||||
|
_attr_supported_features: CoverEntityFeature | int | None
|
||||||
|
|
||||||
_cover_is_last_toggle_direction_open = True
|
_cover_is_last_toggle_direction_open = True
|
||||||
|
|
||||||
@ -291,7 +292,7 @@ class CoverEntity(Entity):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._attr_supported_features is not None:
|
if self._attr_supported_features is not None:
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
@ -38,7 +38,7 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
|
|||||||
"""A cover implementation for ESPHome."""
|
"""A cover implementation for ESPHome."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
flags = (
|
flags = (
|
||||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||||
|
@ -143,7 +143,7 @@ class HomeKitWindowCover(HomeKitEntity, CoverEntity):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
features = (
|
features = (
|
||||||
CoverEntityFeature.OPEN
|
CoverEntityFeature.OPEN
|
||||||
|
@ -380,7 +380,7 @@ class MotionTiltOnlyDevice(MotionTiltDevice):
|
|||||||
_restore_tilt = False
|
_restore_tilt = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = (
|
supported_features = (
|
||||||
CoverEntityFeature.OPEN_TILT
|
CoverEntityFeature.OPEN_TILT
|
||||||
|
@ -535,7 +535,7 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||||||
return self._config.get(CONF_DEVICE_CLASS)
|
return self._config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature | int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = 0
|
||||||
if self._config.get(CONF_COMMAND_TOPIC) is not None:
|
if self._config.get(CONF_COMMAND_TOPIC) is not None:
|
||||||
|
@ -75,7 +75,7 @@ class BlockShellyCover(ShellyBlockEntity, CoverEntity):
|
|||||||
"""Initialize block cover."""
|
"""Initialize block cover."""
|
||||||
super().__init__(coordinator, block)
|
super().__init__(coordinator, block)
|
||||||
self.control_result: dict[str, Any] | None = None
|
self.control_result: dict[str, Any] | None = None
|
||||||
self._attr_supported_features: int = (
|
self._attr_supported_features = (
|
||||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||||
)
|
)
|
||||||
if self.coordinator.device.settings["rollers"][0]["positioning"]:
|
if self.coordinator.device.settings["rollers"][0]["positioning"]:
|
||||||
@ -151,7 +151,7 @@ class RpcShellyCover(ShellyRpcEntity, CoverEntity):
|
|||||||
"""Initialize rpc cover."""
|
"""Initialize rpc cover."""
|
||||||
super().__init__(coordinator, f"cover:{id_}")
|
super().__init__(coordinator, f"cover:{id_}")
|
||||||
self._id = id_
|
self._id = id_
|
||||||
self._attr_supported_features: int = (
|
self._attr_supported_features = (
|
||||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||||
)
|
)
|
||||||
if self.status["pos_control"]:
|
if self.status["pos_control"]:
|
||||||
|
@ -309,7 +309,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
|
|||||||
return self._device_class
|
return self._device_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class VeluxCover(VeluxEntity, CoverEntity):
|
|||||||
"""Representation of a Velux cover."""
|
"""Representation of a Velux cover."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = (
|
supported_features = (
|
||||||
CoverEntityFeature.OPEN
|
CoverEntityFeature.OPEN
|
||||||
|
@ -1108,6 +1108,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
function_name="is_closed",
|
function_name="is_closed",
|
||||||
return_type=["bool", None],
|
return_type=["bool", None],
|
||||||
),
|
),
|
||||||
|
TypeHintMatch(
|
||||||
|
function_name="supported_features",
|
||||||
|
return_type=["CoverEntityFeature", "int"],
|
||||||
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="open_cover",
|
function_name="open_cover",
|
||||||
kwargs_type="Any",
|
kwargs_type="Any",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user