Skip to content

Commit 7d89157

Browse files
razor-xclaude
andauthored
docs: document status-dependent action attempt values (#633)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7a17585 commit 7d89157

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,28 @@ When the ``wait_for_action_attempt`` option is enabled, the SDK:
221221
- Raises a ``SeamActionAttemptTimeoutError`` if the action attempt is still pending when the ``timeout`` is reached.
222222
- Both errors expose an ``action_attempt`` property.
223223

224+
Each action attempt parses to a class for its ``action_type`` and ``status`` pair,
225+
e.g., ``LockDoorSuccessActionAttempt``.
226+
The ``error`` and ``result`` attributes are ``None``
227+
except for the status that populates them,
228+
so narrow on the ``status`` before reading them:
229+
230+
.. code-block:: python
231+
232+
action_attempt = seam.locks.unlock_door(
233+
device_id=device_id,
234+
wait_for_action_attempt=False,
235+
)
236+
237+
if action_attempt.status == "success":
238+
print(action_attempt.result) # The result is not None here.
239+
240+
if action_attempt.status == "error":
241+
print(action_attempt.error.message) # The error is not None here.
242+
243+
Waiting for an action attempt returns a ``SuccessActionAttempt``,
244+
so the ``result`` is immediately usable.
245+
224246
If you already have an action attempt ID
225247
and want to wait for it to resolve, simply use
226248

0 commit comments

Comments
 (0)