mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Enforce CoverEntityFeature (#82457)
* Enforce CoverEntityFeature * Adjust pylint
This commit is contained in:
parent
48cc3071bb
commit
34607d4410
@ -70,9 +70,9 @@ class AcmedaCover(AcmedaBase, CoverEntity):
|
|||||||
return position
|
return position
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> CoverEntityFeature | int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = CoverEntityFeature(0)
|
||||||
if self.current_cover_position is not None:
|
if self.current_cover_position is not None:
|
||||||
supported_features |= (
|
supported_features |= (
|
||||||
CoverEntityFeature.OPEN
|
CoverEntityFeature.OPEN
|
||||||
|
@ -58,7 +58,7 @@ class BondCover(BondEntity, CoverEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Create HA entity representing Bond cover."""
|
"""Create HA entity representing Bond cover."""
|
||||||
super().__init__(hub, device, bpup_subs)
|
super().__init__(hub, device, bpup_subs)
|
||||||
supported_features = 0
|
supported_features = CoverEntityFeature(0)
|
||||||
if self._device.supports_set_position():
|
if self._device.supports_set_position():
|
||||||
supported_features |= CoverEntityFeature.SET_POSITION
|
supported_features |= CoverEntityFeature.SET_POSITION
|
||||||
if self._device.supports_open():
|
if self._device.supports_open():
|
||||||
|
@ -232,7 +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
|
_attr_supported_features: CoverEntityFeature | None
|
||||||
|
|
||||||
_cover_is_last_toggle_direction_open = True
|
_cover_is_last_toggle_direction_open = True
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ class CoverEntity(Entity):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> CoverEntityFeature | int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""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
|
||||||
|
@ -324,7 +324,7 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||||||
tilt_states, ATTR_CURRENT_TILT_POSITION
|
tilt_states, ATTR_CURRENT_TILT_POSITION
|
||||||
)
|
)
|
||||||
|
|
||||||
supported_features = 0
|
supported_features = CoverEntityFeature(0)
|
||||||
if self._covers[KEY_OPEN_CLOSE]:
|
if self._covers[KEY_OPEN_CLOSE]:
|
||||||
supported_features |= CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
supported_features |= CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||||
supported_features |= CoverEntityFeature.STOP if self._covers[KEY_STOP] else 0
|
supported_features |= CoverEntityFeature.STOP if self._covers[KEY_STOP] else 0
|
||||||
|
@ -118,7 +118,7 @@ class PowerViewShadeBase(ShadeEntity, CoverEntity):
|
|||||||
"""Representation of a powerview shade."""
|
"""Representation of a powerview shade."""
|
||||||
|
|
||||||
_attr_device_class = CoverDeviceClass.SHADE
|
_attr_device_class = CoverDeviceClass.SHADE
|
||||||
_attr_supported_features = 0
|
_attr_supported_features = CoverEntityFeature(0)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -516,9 +516,9 @@ class MqttCover(MqttEntity, CoverEntity):
|
|||||||
return self._config.get(CONF_DEVICE_CLASS)
|
return self._config.get(CONF_DEVICE_CLASS)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> CoverEntityFeature | int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = CoverEntityFeature(0)
|
||||||
if self._config.get(CONF_COMMAND_TOPIC) is not None:
|
if self._config.get(CONF_COMMAND_TOPIC) is not None:
|
||||||
if self._config.get(CONF_PAYLOAD_OPEN) is not None:
|
if self._config.get(CONF_PAYLOAD_OPEN) is not None:
|
||||||
supported_features |= CoverEntityFeature.OPEN
|
supported_features |= CoverEntityFeature.OPEN
|
||||||
|
@ -25,9 +25,9 @@ class Awning(OverkizGenericCover):
|
|||||||
_attr_device_class = CoverDeviceClass.AWNING
|
_attr_device_class = CoverDeviceClass.AWNING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features: int = super().supported_features
|
supported_features = super().supported_features
|
||||||
|
|
||||||
if self.executor.has_command(OverkizCommand.SET_DEPLOYMENT):
|
if self.executor.has_command(OverkizCommand.SET_DEPLOYMENT):
|
||||||
supported_features |= CoverEntityFeature.SET_POSITION
|
supported_features |= CoverEntityFeature.SET_POSITION
|
||||||
|
@ -129,9 +129,9 @@ class OverkizGenericCover(OverkizEntity, CoverEntity):
|
|||||||
return attr
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features = 0
|
supported_features = CoverEntityFeature(0)
|
||||||
|
|
||||||
if self.executor.has_command(*COMMANDS_OPEN_TILT):
|
if self.executor.has_command(*COMMANDS_OPEN_TILT):
|
||||||
supported_features |= CoverEntityFeature.OPEN_TILT
|
supported_features |= CoverEntityFeature.OPEN_TILT
|
||||||
|
@ -46,9 +46,9 @@ class VerticalCover(OverkizGenericCover):
|
|||||||
"""Representation of an Overkiz vertical cover."""
|
"""Representation of an Overkiz vertical cover."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
supported_features: int = super().supported_features
|
supported_features = super().supported_features
|
||||||
|
|
||||||
if self.executor.has_command(OverkizCommand.SET_CLOSURE):
|
if self.executor.has_command(OverkizCommand.SET_CLOSURE):
|
||||||
supported_features |= CoverEntityFeature.SET_POSITION
|
supported_features |= CoverEntityFeature.SET_POSITION
|
||||||
|
@ -191,7 +191,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
|
|||||||
super().__init__(device, device_manager)
|
super().__init__(device, device_manager)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
||||||
self._attr_supported_features = 0
|
self._attr_supported_features = CoverEntityFeature(0)
|
||||||
|
|
||||||
# Check if this cover is based on a switch or has controls
|
# Check if this cover is based on a switch or has controls
|
||||||
if self.find_dpcode(description.key, prefer_function=True):
|
if self.find_dpcode(description.key, prefer_function=True):
|
||||||
|
@ -1110,7 +1110,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="supported_features",
|
function_name="supported_features",
|
||||||
return_type=["CoverEntityFeature", "int"],
|
return_type="CoverEntityFeature",
|
||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="open_cover",
|
function_name="open_cover",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user