Get Started with SmartThings Hubs + Thermostats

Learn how to connect and control SmartThings-connected thermostats with the Seam API.

SmartThings Hub + Devices
SmartThings Hub + Devices

Overview

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

This guide gives you a rapid introduction to connecting and controlling your SmartThings-connected thermostats 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.

You connect your thermostats to Seam through a SmartThings Hub. These hubs use Zigbee or Z-Wave to communicate with your thermostats. SmartThings Hubs are connected to your local network using Wi-Fi or Ethernet. For detailed information about the SmatThings Hubs that Seam supports, see our SmartThings Supported Devices page.

To learn more about other IoT device and system brands that Seam supports—such as ecobee, Honeywell Resideo, Google Nest, Yale, Schlage, and many more—visit our integration page.


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=seam_test2bMS_94SrGUXuNR2JmJkjtvBQDg5c

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 SmartThings-connected thermostat, use a non-sandbox workspace and API key.


To control your SmartThings-connected thermostat using the Seam API, you must first authorize your Seam workspace to connect to your SmartThings account. If your application needs to connect to your users' SmartThings 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 SmartThings-connected thermostats. The Connect Webview presents a flow that prompts your users to enter their credentials for their SmartThings 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 SmartThings account.

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=["smartthings"],
  accepted_capabilities=["thermostat"]
)

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.

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

Use the Seam Connect Webview authorization flow to connect a SmartThings account with Seam. This flow varies slightly based on the device manufacturer.
Use the Seam Connect Webview authorization flow to connect a SmartThings account with Seam. This flow varies slightly based on the device manufacturer.

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 SmartThings-connected thermostat devices

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

The Seam API exposes each device's properties, such as the current temperature reading in Fahrenheit and Celsius, current HVAC and fan modes, available climate presets, thermostat-specific constraints, and much more.

Code:

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

# Select the first device as an example.
living_room_thermostat = all_smartthings_thermostats[0]

# Inspect specific properties.
pprint("Current temperature: " + str(living_room_thermostat.properties["temperature_fahrenheit"]))
pprint("Fan running: " + str(living_room_thermostat.properties["is_fan_running"]))

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

Output:

'Current temperature: 70'
'Fan running: False'
Device(
  device_id='11111111-1111-1111-2222-444444444444',
  workspace_id='00000000-0000-0000-0000-000000000000',
  connected_account_id='11111111-1111-1111-1111-222222222222',
  created_at='2024-10-03T22:12:15.666Z',
  properties={
    'manufacturer': 'smartthings',
    'online': True,
    'temperature_celsius': 21.11111111111111,
    'temperature_fahrenheit': 70,
    'relative_humidity': 0.36,
    'is_cooling': False,
    'is_heating': False,
    'is_fan_running': False,
    'current_climate_setting': {
      'display_name': 'Manual Setting',
      'fan_mode_setting': 'auto',
      'heating_set_point_celsius': 21.11111111111111,   
      'heating_set_point_fahrenheit': 70,
      'hvac_mode_setting': 'heat',
      'manual_override_allowed': True
    },
    ...
  },
  can_hvac_cool=True,
  can_hvac_heat=True,
  can_turn_off_hvac=True,
  ...
)

Step 4: Control your SmartThings-connected thermostat

Next, you can use the Seam API to control your SmartThings-connected thermostat.

Each device that you connect to Seam has a specific set of capabilities. These capabilities define the Seam API actions that you can use. For thermostats, device-specific capabilities include whether you can set the HVAC mode to heat, cool, or heat_cool. 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.

Seam provides additional actions for thermostats, such as setting the fan mode, creating and scheduling climate presets, setting temperature thresholds, and configuring weekly thermostat programs. You can also monitor for Seam thermostat-related events, such as reported temperatures outside your set thresholds.

Try out the following actions on your SmartThings-connected thermostat:

Set the HVAC mode

To set the HVAC mode, use any of the following endpoints or their equivalents in the Seam SDKs:

  • /thermostats/heat

  • /thermostats/cool

  • /thermostats/heat_cool (for devices that support this mode)

  • /thermostats/off

  • /thermostats/set_hvac_mode

    This endpoint is a consolidated version of the other four endpoints.

Specify the thermostat that you want to control by including the device_id in the request body. Also, include the desired temperature set point.

In this example, set the HVAC mode to heat and the desired heating set point to 68 °F.

Each of these HVAC mode endpoints returns an action attempt to track the progress of the operation.

Code:

# Confirm that the device supports heat mode.
# You're using a capability flag here!
if living_room_thermostat.can_hvac_heat:
  # Set the HVAC mode
  # and return an action attempt.
  action_attempt = seam.thermostats.heat(
    device_id = living_room_thermostat.device_id,
    heating_set_point_fahrenheit = 68
  )

Output:

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

You can track the status of the operation to confirm that the device was set to heat mode successfully. Query properties.current_climate_setting.hvac_mode_setting for the device, retrieve the action attempt by ID, or look for a thermostat.manually_adjusted event. Further, if you wanted to find out whether the HVAC system was currently heating, you could inspect properties.is_heating for the device.

To query properties.current_climate_setting.hvac_mode_setting for the device:

Code:

# Get the device by ID.
updated_living_room_thermostat = seam.devices.get(
  device_id = living_room_thermostat.device_id
)

# Inspect properties.current_climate_setting.hvac_mode_setting 
# to confirm that setting the HVAC mode to heat was successful.
pprint(
  updated_living_room_thermostat.
  properties["current_climate_setting"]["hvac_mode_setting"]
)

Output:

'heat'

Create and schedule climate presets

You can use the Seam API to create climate presets for SmartThings thermostats. Each climate preset is a saved group of settings, such as HVAC mode, fan mode, and temperature set points. Climate presets make it quick and easy to apply consistent climate settings for different scenarios. For example, you could create two climate presets: a comfort preset for when a vacation rental is occupied and an eco preset for when the vacation rental is empty.

You can schedule climate presets to start and stop whenever you'd like. You can even set a fallback climate preset, such as eco.

In this example, create comfort and eco climate presets, set eco as the fallback, and schedule the comfort climate preset to coincide with two vacation rental reservations.

Code:

# Confirm that the thermostat supports cool mode
# so that the climate presets can use this mode.
if updated_living_room_thermostat.can_hvac_cool:
  # Create the climate presets.
  seam.thermostats.create_climate_preset(
    device_id = updated_living_room_thermostat.device_id,
    climate_preset_key = "comfort",
    name = "Comfort",
    fan_mode_setting = "auto",
    hvac_mode_setting = "cool",
    cooling_set_point_celsius = 25
  )
  
  seam.thermostats.create_climate_preset(
    device_id: updated_living_room_thermostat.device_id,
    climate_preset_key = "eco",
    name = "Eco",
    fan_mode_setting = "auto",
    hvac_mode_setting = "cool",
    cooling_set_point_celsius = 30
  )

  # Then, set eco as the fallback climate setting.
  seam.thermostats.set_fallback_climate_preset(
    device_id = updated_living_room_thermostat.device_id,
    climate_preset_key = "eco"
  )
  
  # Now, schedule the comfort preset to coincide with two reservations.
  seam.thermostats.schedules.create(
    device_id = updated_living_room_thermostat.device_id,
    name = "Jim's stay",
    climate_preset_key = "comfort",
    starts_at = "2025-03-10T15:00:00Z",
    ends_at = "2025-03-15T12:00:00Z",
    is_override_allowed = True,
    max_override_period_minutes = 90
  )
  
  seam.thermostats.schedules.create(
    device_id = updated_living_room_thermostat.device_id,
    name = "Jane's stay",
    climate_preset_key = "comfort",
    starts_at = "2025-03-17T15:00:00Z",
    ends_at = "2025-03-20T12:00:00Z",
    is_override_allowed = True,
    max_override_period_minutes = 90
  )

Output:

ThermostatSchedule(
  thermostat_schedule_id='88888888-1111-1111-1111-111111111111',
  name="Jim's stay",
  device_id='11111111-1111-1111-2222-444444444444',
  climate_preset_key='comfort',
  starts_at='2025-03-10T15:00:00.000Z',
  ends_at='2025-03-15T12:00:00.000Z',
  is_override_allowed=True,
  max_override_period_minutes=90,
  ...
)
ThermostatSchedule(
  thermostat_schedule_id='88888888-1111-1111-1111-222222222222',
  name="Jane's stay",
  device_id='11111111-1111-1111-2222-444444444444',
  climate_preset_key='comfort',
  starts_at='2025-03-17T15:00:00.000Z',
  ends_at='2025-03-20T12:00:00.000Z',
  is_override_allowed=True,
  max_override_period_minutes=90,
  ...
)

Configure a weekly thermostat program

You can use the Seam API to create a thermostat weekly program for your SmartThings-connected thermostat. This standard feature of smart thermostats enables you to define full-week programs that are made up of reusable daily programs. Each daily program consists of a set of thermostat daily program periods, that is, time blocks with associated climate presets.

In this example, create a weekday daily program and a weekend daily program. Then, combine these daily programs into a weekly program by assigning a daily program to each day of the week.

Code:

# Create the daily programs.
weekday_program = seam.thermostats.daily_programs.create(
  device_id = updated_living_room_thermostat.device_id,
  name = "Weekday Program",
  periods = [
    { "starts_at_time": "07:00:00", "climate_preset_key": "Home" },
    { "starts_at_time": "09:00:00", "climate_preset_key": "Away" },
    { "starts_at_time": "18:00:00", "climate_preset_key": "Home" },
    { "starts_at_time": "22:00:00", "climate_preset_key": "Sleep" }
  ]
)

weekend_program = seam.thermostats.daily_programs.create(
  device_id = updated_living_room_thermostat.device_id,
  name = "Weekend Program",
  periods = [
    { "starts_at_time": "08:00:00", "climate_preset_key": "Home" },
    { "starts_at_time": "23:00:00", "climate_preset_key": "Sleep" }
  ]
)

# Use the daily programs to set the weekly program.
seam.thermostats.update_weekly_program(
  device_id = updated_living_room_thermostat.device_id,
  monday_program_id = weekday_program.thermostat_daily_program_id,
  tuesday_program_id = weekday_program.thermostat_daily_program_id,
  wednesday_program_id = weekday_program.thermostat_daily_program_id,
  thursday_program_id = weekday_program.thermostat_daily_program_id,
  friday_program_id = weekday_program.thermostat_daily_program_id,
  saturday_program_id = weekend_program.thermostat_daily_program_id,
  sunday_program_id = weekend_program.thermostat_daily_program_id
)

Output:

ActionAttempt(
  action_attempt_id='11111111-2222-3333-4444-666666666666',
  action_type='PUSH_THERMOSTAT_PROGRAMS',
  status='success',
  result={},
  error=None
)

Step 5: Connect a real SmartThings-connected thermostat

Now that you have learned the basics of using the Seam API, you can connect and control a real SmartThings-connected device. To do so, make sure to switch to a non-sandbox workspace and API key.

For more details about setting up your real SmartThings-connected thermostat, see the SmartThings Hubs + devices integration guide.


Step 6: Build your application!

Seam makes it easy to develop your application. The robust Seam API and Seam SDKs in a wide variety of programming languages provide robust, up-to-date information about your thermostats. We also provide helpful thermostat-related events that enable you to monitor the status of your thermostats and the connected HVAC systems. Further, our simulation endpoints make it easy for you to test your thermostat app against events that can be difficult to orchestrate in your quality assurance (QA) environment using real devices.


Next steps

Now that you've completed this getting started guide for SmartThings-connected devices, you can learn more about what you can do with the Seam API.

If you have any questions or want to report an issue, email us at [email protected].


Last updated

Was this helpful?