File: lock.md

package info (click to toggle)
simplisafe-python 2024.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,268 kB
  • sloc: python: 5,252; sh: 50; makefile: 19
file content (78 lines) | stat: -rw-r--r-- 1,756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Locks

{meth}`Lock <simplipy.lock.Lock>` objects correspond to SimpliSafeā„¢ locks (only
available for V3 systems) and allow users to retrieve information on them and alter
their state by locking/unlocking them.

## Core Properties

All {meth}`Lock <simplipy.lock.Lock>` objects come with a standard set of properties:

```python
for serial, lock in system.locks.items():
    # Return the lock's name:
    lock.name
    # >>> Kitchen Window

    # Return the lock's serial number through the index:
    serial
    # >>> 1234ABCD

    # ...or through the property:
    lock.serial
    # >>> 1234ABCD

    # Return the state of the lock:
    lock.state
    # >>> simplipy.lock.LockStates.LOCKED

    # Return whether the lock is in an error state:
    lock.error
    # >>> False

    # Return whether the lock has a low battery:
    lock.low_battery
    # >>> False

    # Return whether the lock is offline:
    lock.offline
    # >>> False

    # Return a settings dictionary for the lock:
    lock.settings
    # >>> {"autoLock": 3, "away": 1, "home": 1}

    # Return whether the lock is disabled:
    lock.disabled
    # >>> False

    # Return whether the lock's battery is low:
    lock.lock_low_battery
    # >>> False

    # Return whether the pin pad's battery is low:
    lock.pin_pad_low_battery
    # >>> False

    # Return whether the pin pad is offline:
    lock.pin_pad_offline
    # >>> False
```

## Locking/Unlocking

Locking and unlocking a lock is accomplished via two coroutines:

```python
for serial, lock in system.locks.items():
    await lock.async_lock()
    await lock.async_unlock()
```

## Updating the Lock

To retrieve the sensor's latest state/properties/etc., simply:

```python
await lock.async_update(cached=True)
```