Seam Docs
Search…
Get started with SmartThings Hubs + Smart Locks

SmartThings Hub + Smart Lock

SmartThings Hub is connected to your local network using either Wifi or ethernet. The Smart Lock is paired to SmartThings via Zigbee or Z-Wave. These locks can then be remotely locked, unlocked, and have access codes programmed to allow keyless entry.

Overview

To pair a SmartThings Hub and smart lock with our API, we'll need to sign into a SmartThings account. We can do this by creating a Seam Webview.
​
Make sure to install the relevant Seam package for your language...
Python
Javascript
1
from seamapi import Seam
2
​
3
seam = Seam()
4
​
5
webview = seam.connect_webviews.create(accepted_providers=["smartthings"])
6
​
7
assert webview.login_successful is False
8
​
9
# Send the webview URL to your user
10
print(webview.url)
Copied!
1
import Seam from "seamapi"
2
​
3
const seam = Seam()
4
​
5
const webview = await seam.connect_webviews.create({
6
accepted_providers: ["smartthings"]
7
})
8
​
9
console.log(webview)
10
/*
11
{
12
"connect_webview_id": "811b80e7-7c87-4ce1-a938-2f6936851aa9",
13
"url": "https://connect.getseam.com/v1/connect_webviews/view?connect_webview_id=811b80e7-7c87-4ce1-a938-2f6936851aa9&auth_token=GXtMoAaperbuNhSCByyQMroT9HMRquXK6",
14
"device_selection_mode": "none",
15
"accepted_providers": [
16
"smartthings"
17
],
18
"created_at": "2022-01-03T21:11:27.002Z",
19
"login_successful": false,
20
"status": "pending"
21
}
22
*/
Copied!
We should now send the Connect Webview URL to the user, when the user signs in, we'll see a "completed" status on the webview or login_successful set to true.
Python
Javascript
1
updated_webview = seam.connect_webviews.get(webview.connect_webview_id)
2
​
3
assert updated_webview.login_successful
Copied!
1
const updated_webview = await seam.connect_webviews.get(
2
webview.connect_webview_id
3
)
4
​
5
console.log(updated_webview.login_successful)
6
// true
Copied!
We can now find all the devices that are associated with the connected account that was signed into. From the returned payload, see whether the door lock is locked or unlocked.
​
Python
Javascript
1
from pprint import pprint
2
​
3
all_devices = seam.devices.list()
4
​
5
device = all_devices[0]
6
​
7
assert device.properties["online"] is True
8
assert device.properties["locked"] is True
9
​
10
pprint(device)
11
# Device(device_id='a8669e4c-76e3-4db6-a827-11a65eb360ba',
12
# device_type='smartthings_lock',
13
# location=None,
14
# properties={'smartthings_metadata': {...}},
15
# 'locked': True,
16
# 'online': True})
Copied!
1
const all_locks = await seam.locks.list()
2
​
3
const some_lock = all_locks[0]
4
​
5
console.log(some_lock)
6
/*
7
{
8
device_id: 'a8669e4c-76e3-4db6-a827-11a65eb360ba',
9
device_type: 'smartthings_lock',
10
location: null,
11
properties: { smartthings_metadata: {...} },
12
locked: true,
13
online: true
14
}
15
*/
Copied!
​

Locking a Door

post
https://connect.getseam.com
/locks/lock_door
Lock a door
Python
Javascript
1
seam.locks.lock_door(some_device)
2
​
3
updated_device = seam.devices.get(some_device.device_id)
4
​
5
assert updated_device.properties["locked"] is True
Copied!
1
await seam.locks.lock_door({ device: some_device })
2
​
3
const updated_device = await seam.devices.get(some_device)
4
​
5
console.log(updated_device.properties.locked)
6
// true
Copied!
​

Unlocking a Door

post
https://connect.getseam.com
/locks/unlock_door
Unlock a door
Python
Javascript
1
seam.locks.unlock_door(some_device)
2
​
3
updated_device = seam.devices.get(some_device.device_id)
4
​
5
assert updated_device.properties["locked"] is False
Copied!
1
await seam.locks.unlock_door({ lock: some_lock })
2
​
3
const updated_lock = await seam.locks.get(some_lock.device_id)
4
​
5
console.log(updated_lock.properties.locked)
6
// false
Copied!
​

Create an Access Code

post
https://connect.getseam.com
/access_codes/create
Create an Access Code
For Scheduled Access Codes, both starts_at and ends_at are required. For Ongoing Access Codes, don't set starts_at or ends_at.
Python
Javascript
1
access_code = seam.access_codes.create(
2
device=some_lock,
3
name="new code",
4
code="876543",
5
starts_at="2022-01-13T21:17:56.138Z",
6
ends_at="2022-01-13T21:17:58.138Z"
7
)
8
​
9
pprint(access_code)
10
# AccessCode(
11
# access_code_id='a8669e4c-76e3-4db6-a827-11a65eb360ba',
12
# type='ongoing',
13
# name='new code',
14
# code='876543',
15
# starts_at='2022-01-13T21:17:56.138Z'
16
# ends_at='2022-01-13T21:17:58.138Z',
17
# location=None,
18
# )
Copied!
1
const access_code = await seam.access_codes.create({
2
lock: some_lock,
3
code: "876543",
4
})
5
​
6
console.log(access_code)
7
/*
8
{
9
"access_code_id": "a8669e4c-76e3-4db6-a827-11a65eb360ba",
10
"code": "876543",
11
"type": "ongoing",
12
"starts_at": "2022-01-13T21:17:56.138Z",
13
"ends_at": null
14
}
15
*/
Copied!
​

Delete an Access Code

delete
https://connect.getseam.com
/access_codes/remove
Remove an Access Code
Python
Javascript
1
attempt = seam.access_codes.delete(access_code=access_code)
2
​
3
pprint(attempt)
4
# ActionAttempt(
5
# action_attempt_id='af0155aa-51fe-4e63-9acb-2fbd33675cac',
6
# action_type='DELETE_ACCESS_CODE',
7
# status='success',
8
# result={},
9
# error=None
10
# )
Copied!
1
await seam.access_codes.remove({
2
code: access_code
3
})
Copied!
​

List Access Codes

get
https://connect.getseam.com
/access_codes
List Access Codes
Python
Javascript
1
# you can use a device or a device_id as the "device" parameter
2
seam.access_codes.list(device=some_lock)
3
# [
4
# AccessCode(
5
# access_code_id='af5272b1-2a49-4eb5-9388-2447fc7b5bd1',
6
# type='ongoing',
7
# code='123459',
8
# starts_at=None,
9
# ends_at=None,
10
# name='ongoing 1'
11
# ),
12
# AccessCode(
13
# access_code_id='57f8216a-ebc4-46e7-8f89-9c9448f70733',
14
# type='ongoing',
15
# code='189644',
16
# starts_at=None,
17
# ends_at=None,
18
# name='ongoing 2'
19
# )
20
# ]
Copied!
1
// you can use a device or a device_id as the "device" parameter
2
const access_codes = await seam.access_codes.list({
3
device: {
4
"device_id": "af5272b1-2a49-4eb5-9388-2447fc7b5bd1"
5
}
6
})
7
​
8
console.log(access_codes)
9
/*
10
[
11
{
12
"access_code_id": "a8669e4c-76e3-4db6-a827-11a65eb360ba",
13
"code": "876543",
14
"type": "ongoing",
15
"starts_at": "2022-01-13T21:17:56.138Z",
16
"ends_at": null
17
}
18
]
19
*/
Copied!
​