File: system.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 (313 lines) | stat: -rw-r--r-- 8,536 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# Systems

{meth}`System <simplipy.system.System>` objects are used to retrieve data on and control the state
of SimpliSafe™ systems. Two types of objects can be returned:

- {meth}`SystemV2 <simplipy.system.v2.SystemV2>`: an object to control V2 (classic)
  SimpliSafe™ systems
- {meth}`SystemV3 <simplipy.system.v3.SystemV3>`: an object to control V3 (new, released
  in 2018) SimpliSafe™ systems

Despite the differences, `simplipy` provides a common interface to
these objects, meaning many of the same properties and methods are available to
both.

To get all SimpliSafe™ systems associated with an account:

```python
import asyncio

from aiohttp import ClientSession
import simplipy


async def main() -> None:
    """Create the aiohttp session and run."""
    async with ClientSession() as session:
        api = await simplipy.API.async_from_auth(
            "<AUTHORIZATION_CODE>",
            "<CODE_VERIFIER>",
            session=session,
        )

        # Get a dict of systems with the system ID as the key:
        systems = await api.async_get_systems()
        # >>> {"1234abc": <simplipy.system.SystemV2 object>, ...}


asyncio.run(main())
```

## Core Properties

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

```python
# Return the street address of the system:
system.address
# >>> 1234 Main Street

# Return whether the alarm is currently going off:
system.alarm_going_off
# >>> False

# Return the type of connection the system is using:
system.connection_type
# >>> "cell"

# Return a list of active notifications:
system.notifications
# >>> [<simplipy.system.SystemNotification object>, ...]

# Return a list of sensors attached to this system
# (detailed later):
system.sensors
# >>> [<simplipy.sensor.SensorV2 object>, ...]

# Return the system's serial number:
system.serial
# >>> xxxxxxxxxxxxxx

# Return the current state of the system:
system.state
# >>> simplipy.system.SystemStates.AWAY

# Return the SimpliSafe™ identifier for this system
# from the key:
system_id
# >>> 1234abc

# ...or as a property of the system itself:
system.system_id
# >>> 1234abc

# Return the average of all temperature sensors
# (if they exist):
system.temperature
# >>> 67

# Return the SimpliSafe™ version:
system.version
# >>> 2
```

## V3 Properties

If a {meth}`System <simplipy.system.v3.SystemV3>` object should be a V3 system, it will
automatically come with additional properties:

```python
# Return the number of seconds an activated alarm
# will sound for:
system.alarm_duration
# >>> 240

# Return the loudness of the alarm volume:
system.alarm_volume
# >>> 3

# Return the power rating of the battery backup:
system.battery_backup_power_level
# >>> 5239

# Return the number of seconds to delay when returning
# to an "away" alarm:
system.entry_delay_away
# >>> 30

# Return the number of seconds to delay when returning
# to an "home" alarm:
system.entry_delay_home
# >>> 30

# Return the number of seconds to delay when exiting
# an "away" alarm:
system.exit_delay_away
# >>> 60

# Return the number of seconds to delay when exiting
# an "home" alarm:
system.exit_delay_home
# >>> 0

# Return the signal strength of the cell antenna:
system.gsm_strength
# >>> -73

# Return whether the base station light is on:
system.light
# >>> True

# Return any active system messages/notifications
system.notifications
# >>> [Message(...)]

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

# Return whether the system is experiencing a power
# outage:
system.power_outage
# >>> False

# Return whether the base station is noticing RF jamming:
system.rf_jamming
# >>> False

# Return the loudness of the voice prompt:
system.voice_prompt_volume
# >>> 2

# Return the power rating of the A/C outlet:
system.wall_power_level
# >>> 5239

# Return the ssid of the base station:
system.wifi_ssid
# >>> "My_SSID"

# Return the signal strength of the wifi antenna:
system.wifi_strength
# >>> -43
```

V3 systems also come with a {meth}`async_set_properties <simplipy.system.v3.SystemV3.async_set_properties>`
method to update the following system properties:

- `alarm_duration` (in seconds): 30-480
- `alarm_volume`: Volume.OFF, Volume.LOW, Volume.MEDIUM, Volume.HIGH
- `chime_volume`: Volume.OFF, Volume.LOW, Volume.MEDIUM, Volume.HIGH
- `entry_delay_away` (in seconds): 30-255
- `entry_delay_home` (in seconds): 0-255
- `exit_delay_away` (in seconds): 45-255
- `exit_delay_home` (in seconds): 0-255
- `light`: True or False
- `voice_prompt_volume`: Volume.OFF, Volume.LOW, Volume.MEDIUM, Volume.HIGH

Note that the `simplipy.system.v3.Volume` enum class should be used for volume
properties.

```python
from simplipy.system.v3 import Volume

await system.async_set_properties(
    {
        "alarm_duration": 240,
        "alarm_volume": Volume.HIGH,
        "chime_volume": Volume.MEDIUM,
        "entry_delay_away": 30,
        "entry_delay_home": 30,
        "exit_delay_away": 60,
        "exit_delay_home": 0,
        "light": True,
        "voice_prompt_volume": Volume.MEDIUM,
    }
)
```

Attempting to call these coroutines with a value beyond these limits will raise a
{meth}`SimplipyError <simplipy.errors.SimplipyError>`.

## Updating the System

Refreshing the {meth}`System <simplipy.system.System>` object is done via the
{meth}`update() <simplipy.system.System.update>` coroutine:

```python
await system.async_update()
```

Note that this method can be supplied with four optional parameters (all of which
default to `True`):

- `include_system`: update the system state and properties
- `include_settings`: update system settings (like PINs)
- `include_entities`: update all sensors/locks/etc. associated with a system
- `cached`: use the last values provides by the base station

For instance, if a user only wanted to update sensors and wanted to force a new data
refresh:

```python
await system.async_update(include_system=False, include_settings=False, cached=False)
```

There are two crucial differences between V2 and V3 systems when updating:

- V2 systems, which use only 2G cell connectivity, will be slower to update
  than V3 systems when those V3 systems are connected to WiFi.
- V2 systems will audibly announce, "Your settings have been synchronized."
  when the update completes; V3 systems will not. Unfortunately, this cannot
  currently be worked around.

## Arming/Disarming

Arming the system in home/away mode and disarming the system are done via a set
of three coroutines:

```python
await system.async_set_away()
await system.async_set_home()
await system.async_set_off()
```

## Events

The {meth}`System <simplipy.system.System>` object allows users to view events that have
occurred with their system:

```python
from datetime import datetime, timedelta

yesterday = datetime.now() - timedelta(days=1)

await system.async_get_events(from_timestamp=yesterday, num_events=2)
# >>> [{"eventId": 123, ...}, {"eventId": 456, ...}]

await system.async_get_latest_event()
# >>> {"eventId": 987, ...}
```

## System Notifications

The `notifications` property of the {meth}`System <simplipy.system.System>` object
contains any active system notifications (in the form of
{meth}`SystemNotification <simplipy.system.SystemNotification>` objects).

Notifications remain within `system.notifications` until cleared, which can be
accomplished by:

1. Manually clearing them in the SimpliSafe™ web and mobile applications
2. Using the {meth}`system.clear_notifications <simplipy.system.System.clear_notifications>`
   coroutine.

## PINs

`simplipy` allows users to easily retrieve, set, reset, and remove PINs
associated with a SimpliSafe™ account:

```python
# Get all PINs (retrieving fresh or from the cache):
await system.async_get_pins(cached=False)
# >>> {"master": "1234", "duress": "9876"}

# Set a new user PIN:
await system.async_set_pin("My New User", "1122")
await system.async_get_pins(cached=False)
# >>> {"master": "1234", "duress": "9876", "My New User": "1122"}

# Remove a PIN (by value or by label)
await system.async_remove_pin("My New User")
await system.async_get_pins(cached=False)
# >>> {"master": "1234", "duress": "9876"}

# Set the master PIN (works for the duress PIN, too):
await system.async_set_pin("master", "9865")
await system.async_get_pins(cached=False)
# >>> {"master": "9865", "duress": "9876"}
```

Remember that with V2 systems, many operations – including setting PINs – will cause
the base station to audibly announce "Your settings have been synchronized."