Device Actions: Examples of Single API Calls with Asynchrounous Resolution
Action! Toggle Lock Status! (Request #15)
The lockStatus trait action provides a way to change the actuating state of the lock latch. Setting the lockStatus state attribute to TOGGLE (one of the enum options) will actuate the lock latching mechanism to either unlocked (if the lock is currently locked) or locked (if the lock is currently unlocked).
Send the request. You will hear the lock audibly actuate.
Now, turn the outside lock handle to confirm the lock status is opposite what it was before you sent the request. Send the request again to confirm your success.
Notice the Action ID returned in the response body. For this request we only need hear the change occur to know it was successful, but for future requests we’ll look at the action event by its Action ID.
Action! Set Lock Display Name (Request #16)
The setDisplayName trait action allows us to change the display name of the lock. This is the name that will advertise over BLE for the lock when scanning. (When testing, be sure to restart any apps and disable/enable BLE before scanning.)
For this request we’ll look at the resolution of the response in two different ways:
- We’ll look for at webhook events for a relevant event with matching action ID, event type of
DEVICE_ACTION_UPDATEDevent with a status of ‘RESOLVED’. - We’ll query (poll) the status of all events with a matching action ID and identify if one exists with event type
DEVICE_ACTION_UPDATEDevent and status of ‘RESOLVED’.
Important: Polling is not a best practice for your application. Polling implemented in a production app will not meet certification standards.
What made this section unhelpful for you?
On this page
- Device Actions: Examples of Single API Calls with Asynchrounous Resolution