diff --git a/blog/2024-05-10-lock supports open state.md b/blog/2024-05-10-lock supports open state.md new file mode 100644 index 00000000..691c27ab --- /dev/null +++ b/blog/2024-05-10-lock supports open state.md @@ -0,0 +1,33 @@ +--- +author: G Johansson +authorURL: https://github.com/gjohansson-ST +title: "LockEntity supports open/opening state" +--- + +Recently we have added a `open` and `opening` state to `LockEntity` + +This is useful if you have locks which can differentiate between `unlocked` (not locked but latched) state and `open` (unlocked and latch withdrawn) state. + +`LockEntity` already supports the [`open` method](/docs/core/entity/lock#open) by implementing the feature flag `LockEntityFeature.OPEN` + +Example (default implementation): + +```python +class MyLock(LockEntity): + + @property + def is_opening(self) -> bool: + """Return true if lock is open.""" + return self._state == STATE_OPENING + + @property + def is_open(self) -> bool: + """Return true if lock is open.""" + return self._state == STATE_OPEN + + async def async_open(self, **kwargs: Any) -> None: + """Open the door latch.""" + self._state = STATE_OPEN + self.async_write_ha_state() + +``` \ No newline at end of file diff --git a/docs/core/entity/lock.md b/docs/core/entity/lock.md index 1607c375..548f9ead 100644 --- a/docs/core/entity/lock.md +++ b/docs/core/entity/lock.md @@ -19,6 +19,8 @@ Properties should always only return information from memory and not do I/O (lik | is_locking | bool | None | Indication of whether the lock is currently locking. Used to determine `state`. | is_unlocking | bool | None | Indication of whether the lock is currently unlocking. Used to determine `state`. | is_jammed | bool | None | Indication of whether the lock is currently jammed. Used to determine `state`. +| is_opening | bool | None | Indication of whether the lock is currently opening. Used to determine `state`. +| is_open | bool | None | Indication of whether the lock is currently open. Used to determine `state`. ## Supported Features