Enforce LockEntityFeature (#82461)
parent
7f1e1ed1d8
commit
a225fc456f
|
@ -38,9 +38,11 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity):
|
||||||
return self._static_info.assumed_state
|
return self._static_info.assumed_state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> LockEntityFeature | int:
|
def supported_features(self) -> LockEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return LockEntityFeature.OPEN if self._static_info.supports_open else 0
|
if self._static_info.supports_open:
|
||||||
|
return LockEntityFeature.OPEN
|
||||||
|
return LockEntityFeature(0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def code_format(self) -> str | None:
|
def code_format(self) -> str | None:
|
||||||
|
|
|
@ -112,7 +112,7 @@ class LockEntity(Entity):
|
||||||
_attr_is_unlocking: bool | None = None
|
_attr_is_unlocking: bool | None = None
|
||||||
_attr_is_jammed: bool | None = None
|
_attr_is_jammed: bool | None = None
|
||||||
_attr_state: None = None
|
_attr_state: None = None
|
||||||
_attr_supported_features: LockEntityFeature | int = 0
|
_attr_supported_features: LockEntityFeature = LockEntityFeature(0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def changed_by(self) -> str | None:
|
def changed_by(self) -> str | None:
|
||||||
|
@ -193,6 +193,6 @@ class LockEntity(Entity):
|
||||||
return STATE_LOCKED if locked else STATE_UNLOCKED
|
return STATE_LOCKED if locked else STATE_UNLOCKED
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> LockEntityFeature | int:
|
def supported_features(self) -> LockEntityFeature:
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
return self._attr_supported_features
|
return self._attr_supported_features
|
||||||
|
|
|
@ -136,9 +136,9 @@ class MqttLock(MqttEntity, LockEntity):
|
||||||
entity=self,
|
entity=self,
|
||||||
).async_render_with_possible_json_value
|
).async_render_with_possible_json_value
|
||||||
|
|
||||||
self._attr_supported_features = (
|
self._attr_supported_features = LockEntityFeature(0)
|
||||||
LockEntityFeature.OPEN if CONF_PAYLOAD_OPEN in config else 0
|
if CONF_PAYLOAD_OPEN in config:
|
||||||
)
|
self._attr_supported_features |= LockEntityFeature.OPEN
|
||||||
|
|
||||||
def _prepare_subscribe_topics(self) -> None:
|
def _prepare_subscribe_topics(self) -> None:
|
||||||
"""(Re)Subscribe to topics."""
|
"""(Re)Subscribe to topics."""
|
||||||
|
|
|
@ -1583,7 +1583,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="supported_features",
|
function_name="supported_features",
|
||||||
return_type=["LockEntityFeature", "int"],
|
return_type="LockEntityFeature",
|
||||||
),
|
),
|
||||||
TypeHintMatch(
|
TypeHintMatch(
|
||||||
function_name="lock",
|
function_name="lock",
|
||||||
|
|
Loading…
Reference in New Issue