diff --git a/homeassistant/components/demo/lock.py b/homeassistant/components/demo/lock.py index 546161b2d6f..47187d5ffc6 100644 --- a/homeassistant/components/demo/lock.py +++ b/homeassistant/components/demo/lock.py @@ -60,7 +60,6 @@ class DemoLock(LockEntity): ) -> None: """Initialize the lock.""" self._attr_name = name - self._attr_supported_features = 0 if openable: self._attr_supported_features = LockEntityFeature.OPEN self._state = state diff --git a/homeassistant/components/esphome/lock.py b/homeassistant/components/esphome/lock.py index bcfa0131518..12666971d71 100644 --- a/homeassistant/components/esphome/lock.py +++ b/homeassistant/components/esphome/lock.py @@ -38,7 +38,7 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity): return self._static_info.assumed_state @property - def supported_features(self) -> int: + def supported_features(self) -> LockEntityFeature | int: """Flag supported features.""" return LockEntityFeature.OPEN if self._static_info.supports_open else 0 diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index a8166e9e3bd..412e314da0f 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -112,6 +112,7 @@ class LockEntity(Entity): _attr_is_unlocking: bool | None = None _attr_is_jammed: bool | None = None _attr_state: None = None + _attr_supported_features: LockEntityFeature | int = 0 @property def changed_by(self) -> str | None: @@ -190,3 +191,8 @@ class LockEntity(Entity): if (locked := self.is_locked) is None: return None return STATE_LOCKED if locked else STATE_UNLOCKED + + @property + def supported_features(self) -> LockEntityFeature | int: + """Return the list of supported features.""" + return self._attr_supported_features diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 2d29ea2fb1a..52d14562dec 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1581,6 +1581,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { function_name="is_jammed", return_type=["bool", None], ), + TypeHintMatch( + function_name="supported_features", + return_type=["LockEntityFeature", "int"], + ), TypeHintMatch( function_name="lock", kwargs_type="Any",