Training: Working with Devices
We already reviewed the 3 Trait Action types:
- Single API Call Actions with synchronous resolution lifecycle – resolved by API response.
- Single API Call Actions with asynchronous resolution lifecycle – resolved by webhook event
- Two-Step Upload Actions with asynchronous resolution lifecycle – resolved by webhook event
We’ll execute actions and process the webhook events we receive upon making action requests.
In the Device Query section we will perform the following:
- Query to list claimed devices
- Query some of the traits of a device including battery trait, lock status, device display details
- Execute Single API Calls with Asynchronous Resolution:
- Set the Lock Display Name & Get Status by Action ID (webhook event, API request)
- Set Auto-Relock Setting
- Get Lock Credentials and Schedules (Returns URL)
- Execute a Two-Step API Call with Asynchronous Resolution:
- Set Credentials & Schedules, Step 1: Get the Upload URL
- Get Status of the request- see AWAITING DATA for action status
- Set Credentials & Schedules, Step 2: Upload JSON Payload
- Get Status of Action Request to Upload JSON (confirm action succeeded)
- Get Lock Credentials & Schedules Again (Confirm change)
- Finally, Test your Credential!
Understanding Traits and Trait Actions is key to managing devices on Yonomi Platform.
Trait Actions are the mechanism Yonomi Platform supports to modify the state of a device. Examples of modifying device state include changing a property such as a device’s display name, adding credentials and schedules or increasing auto-lock timer settings. Trait Actions will use one of the 3 lifecycle patterns described earlier in training. Trait Actions operate on the traits – or behaviors and properties – exposed on a device. Note that trait actions – implemented as GraphQL mutations - are different than queries, which only read device state.
The next section provides a summary of the different Trait Actions available, the Traits on which they operate, and the lifecycle pattern used to support action interactions. We’ll use many of them through the remainder of training.
What made this section unhelpful for you?
On this page
- Training: Working with Devices