Get started with 4SUITES locks

Learn how to connect and control 4SUITES locks with the Seam API.

Overview

Seam provides a universal API to connect and control many brands of IoT devices and systems, including smart locks, access control systems (ACSs), thermostats, and noise sensors.

This guide gives you a rapid introduction to connecting and controlling your 4SUITES lock using the Seam API. For application developers, you can use the Seam API in your app, and your users can authorize your app to control their devices using Seam.

Seam supports the following 4SUITES locks:

To learn more about other IoT device and system brands that Seam supportsโ€”such as Yale, Schlage, Google Nest, and many moreโ€”visit our integration page.

This guide shows you how to install a Seam SDK and then control your 4SUITES lock using the Seam API.

Another easy way to learn about what you can do with the Seam API is to explore the interactive Seam CLI, which you can access from directly within the Seam Console.

โ–ถ๏ธ Go to the Seam Console!


Step 1: Install a Seam SDK

Seam provides client libraries for many languages, including JavaScript, Python, Ruby, PHP, and others, as well as a Postman collection and an OpenAPI spec.

First, install a Seam SDK, as follows:

npm i seam

Next, go to https://console.seam.co/ and sign up for Seam to get your API key.

Then, export your API key as an environment variable.

$ export SEAM_API_KEY=my_seam_api_key

Where my_seam_api_key is your API key.

This guide uses a sandbox workspace. You can only connect virtual devices and systems in this type of workspace. If you want to connect a real 4SUITES lock, use a non-sandbox workspace and API key.


To control your 4SUITES lock using the Seam API, you must first authorize your Seam workspace to connect to your 4SUITES account. If your application needs to connect to your users' 4SUITES accounts, Seam provides fully-embedded, customizable client-side Connect Webviews to collect their authorization securely. These user-friendly pre-built authorization flows walk your users through the process of granting your Seam workspace permission to control their 4SUITES locks. The Connect Webview presents a flow that prompts your users to enter their credentials for their 4SUITES account.

In this guide, you create a Connect Webview object. Then, you display the graphical component of the created Connect Webview and enter a set of sample credentials to connect a sandbox 4SUITES account.

This guide shows you how to create a Connect Webview programmatically using the Seam API.

The Seam Console provides another easy way to connect devices to your Seam workspace.

Go to https://console.seam.co/. On the Devices page, click + Add Devices. Then, see Authorize your workspace in this guide to complete the Connect Webview authorization flow.

Create a Connect Webview

Create a connect_webview object and then note the returned URL.

Code:

from seam import Seam

seam = Seam()  # Seam automatically uses your exported SEAM_API_KEY.

connect_webview = seam.connect_webviews.create(accepted_providers=["four_suites"])

assert connect_webview.login_successful is False

# Use the returned Connect Webview URL to display
# the Connect Webview authorization flow to your user.
print(connect_webview.url)

Output:

https://connect.getseam.com/connect_webviews/view?connect_webview_id=12345678-1234-1234-1234-123456789012&auth_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Authorize your workspace

In a web browser, go to the URL that the Connect Webview object returned.

For application developers, you can redirect your user to this Connect Webview URL so that they can authorize your app to control their devices using Seam. We even provide a prebuilt Connect Account Button within our suite of Seam Components that help you build your device management flow.

Because you're using a sandbox workspace, you can connect Seam's test 4SUITES account. We provide virtual devices for each of the brands that we support. These sandbox devices and systems enable you to test your app with devices from multiple brands without the need to own all the corresponding physical devices.

Complete the Connect Webview authorization flow by entering the following 4SUITES sandbox account credentials:

  • Email: jane@example.com

  • Password: 1234

Confirm that authorization through the Connect Webview was successful by querying its status.

Code:

updated_connect_webview = seam.connect_webviews.get(connect_webview.connect_webview_id)

assert updated_connect_webview.login_successful is True # True

Output:

True

Step 3: Retrieve 4SUITES lock devices

When you link a 4SUITES account with Seam, we create a device object to represent each 4SUITES lock in your account. You can then retrieve these 4SUITES devices using the List Devices and Get Device endpoints.

The Seam API exposes each device's properties, such as the door lock status, power status, capabilities, and so on.

Code:

# Retrieve all devices, filtered by manufacturer,
# which is one of several filters that list() supports.
all_four_suites_locks = seam.devices.list(manufacturer="four_suites")

# Select the first device as an example.
front_door = all_four_suites_locks[0]

# Inspect specific properties.
assert front_door.properties["online"] is True # True
assert front_door.properties["locked"] is True # True

# View the entire returned device object.
pprint(front_door)

Output:

Device(
  device_id='11111111-1111-1111-1111-444444444444',
  display_name='Lock 1',
  workspace_id='00000000-0000-0000-0000-000000000000'
  connected_account_id='11111111-1111-1111-1111-222222222222',
  created_at='2024-05-29T20:08:48.878Z',
  properties={
    'manufacturer': 'four_suites',
    'online': True,
    'locked': True,
    'has_direct_power': True,
    ...
  }
  can_remotely_unlock=True,
  ...
)

Step 4: Control your 4SUITES lock

Next, you can use the Seam API to control your lock.

Each device that you connect to Seam has a specific set of capabilities. These capabilities define the Seam API actions that you can use, such as remote unlock actions, programming access codes, and so on. Seam's intuitive and granular capability flags inform your application about what features and behaviors each device supports. Notice the capability flags within the code samples in this guide.

Try out the following actions on your 4SUITES lock:

Unlock your lock

To unlock a door, use the Unlock Door endpoint. Specify the device that you want to unlock by including the device_id in the request body. This endpoint returns an action attempt to track the progress of the unlock operation.

Code:

# Confirm that the device can remotely unlock.
# You're using a capability flag here!
if front_door.can_remotely_unlock:
  # Perform the unlock operation
  # and return an action attempt.
  action_attempt=seam.locks.unlock_door(device_id=front_door.device_id)

Output:

ActionAttempt(
  status='pending',
  action_type='UNLOCK_DOOR',
  action_attempt_id='11111111-2222-3333-4444-555555555555',
  result=None,
  error={}
)

You can track the status of the unlock operation to confirm that the device unlocked successfully. Query the locked status of the device, retrieve the action attempt by ID, or look for a lock.unlocked event.

To query the locked status of the device:

Code:

# Get the device by ID.
updated_front_door = seam.devices.get(device_id=front_door.device_id)

# Inspect the locked property to confirm
# that the unlock operation was successful.
assert updated_front_door.properties["locked"] is False # False

Output:

False