mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-18 23:06:31 +00:00
Adding documentation for Lock entity (#378)
* Adding documentation for Lock entity * Cleanup from review Remove unnecessary states section and unsupported usercode functions
This commit is contained in:
parent
dc828d4e7b
commit
3e2998b5d0
@ -3,7 +3,7 @@ title: Lock Entity
|
||||
sidebar_label: Lock
|
||||
---
|
||||
|
||||
> This entry is incomplete. Contribution welcome.
|
||||
A lock entity is a device which is able to lock and unlock. Locking and unlocking can optionally be secured with a user code. Some locks also allow for opening of latches, this may also be secured with a user code.
|
||||
|
||||
## Properties
|
||||
|
||||
@ -11,6 +11,54 @@ sidebar_label: Lock
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| changed_by | string | None | Describes what the last change was triggered by.
|
||||
| code_format | string | None | Regex for code format or None if no code is required.
|
||||
| is_locked | bool | None | Indication of whether the lock is currently locked. Used to determine `state`.
|
||||
|
||||
### Supported Features
|
||||
|
||||
Supported features constants are combined using the bitwise or (`|`) operator.
|
||||
|
||||
| Constant | Description |
|
||||
|----------|--------------------------------------|
|
||||
| `SUPPORT_OPEN` | This lock supports opening the door latch.
|
||||
|
||||
## Methods
|
||||
|
||||
### Lock
|
||||
|
||||
```python
|
||||
class MyLock(LockDevice):
|
||||
|
||||
def lock(self, **kwargs):
|
||||
"""Lock all or specified locks. A code to lock the lock with may optionally be specified."""
|
||||
|
||||
async def async_lock(self, **kwargs):
|
||||
"""Lock all or specified locks. A code to lock the lock with may optionally be specified."""
|
||||
```
|
||||
|
||||
### Unlock
|
||||
|
||||
```python
|
||||
class MyLock(LockDevice):
|
||||
|
||||
def unlock(self, **kwargs):
|
||||
"""Unlock all or specified locks. A code to unlock the lock with may optionally be specified."""
|
||||
|
||||
async def async_unlock(self, **kwargs):
|
||||
"""Unlock all or specified locks. A code to unlock the lock with may optionally be specified."""
|
||||
```
|
||||
|
||||
### Open
|
||||
|
||||
Only implement this method if the flag `SUPPORT_OPEN` is set.
|
||||
|
||||
```python
|
||||
class MyLock(LockDevice):
|
||||
|
||||
def open(self, **kwargs):
|
||||
"""Open (unlatch) all or specified locks. A code to open the lock with may optionally be specified."""
|
||||
|
||||
async def async_open(self, **kwargs):
|
||||
"""Open (unlatch) all or specified locks. A code to open the lock with may optionally be specified."""
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user