Get Started with Nest Thermostats

Learn how to connect and control your Google Nest devices with the Seam API.

Overview

Seam provides a universal API to connect and control many brands of devices such as smart locks, thermostats, and sensors. This guide provides a rapid introduction to connecting and controlling your Google Nest thermostats using the Seam API. To learn more about other brands of devices supported by Seam, head over to our integration page.

1. Install Seam SDK

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

npm i seam

Once installed, sign-up for Seam to get your API key and export it as an environment variable:

$ export SEAM_API_KEY=seam_test2ZTo_0mEYQW2TvNDCxG5Atpj85Ffw

This guide uses a sandbox workspace. You can only connect virtual thermostats to a sandbox workspace. If you need to connect a real Google Nest device, use a non-sandbox workspace and API key.

To control your Google Nest device using the Seam API, you must first authorize your Seam workspace against your Google Nest account. To do so, Seam provides Connect Webviews: pre-built UX flows that walk you through authorizing your application to control your Google Nest device.

Create a Connect Webview

from seamapi import Seam
seam = Seam()

webview = seam.connect_webviews.create(accepted_providers=["google_nest"])

assert webview.login_successful is False

# Send the Connect Webview URL to your user.
print(webview.url)

Authorize Your Workspace

Navigate to the URL that the Connect Webview object returns. Because you are using a sandbox workspace, complete the login flow by entering the following Google Nest sandbox test account credentials:

  • email: jane@example.com

  • password: 1234

Get the New Connect Webview

After you complete the authorization login, you receive an event for connected_account.created if you set up a webhook handler. Otherwise, you can poll for the Connect Webview until the status of this Connect Webview changes, as follows:

updated_webview = seam.connect_webviews.get(
    webview.connect_webview_id
)

assert updated_webview.login_successful # true

3. Retrieve your Google Nest Thermostat

Google Nest thermostats appear with the device_type "nest_thermostat".

devices = seam.devices.list(device_type="nest_thermostat")

pprint(devices[0])
# Device(device_id='054765c8-a2fc-4599-b486-14c19f462c45',
#       device_type='nest_thermostat',
#       location=None,
#       properties={'available_hvac_mode_settings': ['heat',
#                                                    'cool',
#                                                    'heat_cool',
#                                                    'off'],
#                   'can_enable_automatic_cooling': True,
#                   'can_enable_automatic_heating': True,
#                   'current_climate_setting': {'automatic_cooling_enabled': True,
#                                               'automatic_heating_enabled': True,
#                                               'cooling_set_point_celsius': 21.5,
#                                               'cooling_set_point_fahrenheit': 70.7,
#                                               'heating_set_point_celsius': 20,
#                                               'heating_set_point_fahrenheit': 68,
#                                               'hvac_mode_setting': 'heat_cool',
#                                               'manual_override_allowed': True},
#                   'has_direct_power': True,
#                   'image_alt_text': 'Placeholder Lock Image',
#                   'image_url': 'https://connect.getseam.com/assets/images/devices/unknown-lock.png',
#                   'is_climate_setting_schedule_active': False,
#                   'is_cooling': False,
#                   'is_fan_running': False,
#                   'is_heating': False,
#                   'is_temporary_manual_override_active': False,
#                   'manufacturer': 'nest',
#                   'model': {'accessory_keypad_supported': False,
#                             'display_name': 'Thermostat',
#                             'manufacturer_display_name': 'Nest'},
#                   'name': '',
#                   'nest_metadata': {'custom_name': '',
#                                     'device_name': 'enterprises/nest_project_id/devices/AVPHwEvjFcX-wRmGdXApyxON24SAI0S9oU13a2GSVFLPVehUKH1ATqlASyKi2N2dbJCVW-B6-VxgbhdjUyyjA-K3Vo5C9g',
#                                     'nest_device_id': 'bcca8c5f-1854-4906-9911-c877d513e00a'},
#                   'online': True,
#                   'relative_humidity': 0.46,
#                   'temperature_celsius': 24.64,
#                   'temperature_fahrenheit': 76.352},
#       capabilities_supported=['thermostat'],
#       errors=[],
#       warnings=[],
#       connected_account_id='44284499-a50b-4947-86c1-58264f014be5',
#       workspace_id='398d80b7-3f96-47c2-b85a-6f8ba21d07be',
#       created_at='2024-02-29T21:57:33.397Z',
#       is_managed=True)

4. Set the Current HVAC and Fan Mode Settings

Seam enables you to adjust the current heating and cooling settings on a smart thermostat, including the HVAC mode and the corresponding set points. It also enables you to configure the fan mode. These two operations return action attempts.

For example, use the following code samples to set your thermostat to heat mode and the fan mode to on:

heat_request = seam.thermostats.heat(
  device = "054765c8-a2fc-4599-b486-14c19f462c45",
  heating_set_point_celsius = 20
)
pprint(heat_request)

# ActionAttempt(action_attempt_id='97125745-15d9-4970-b5be-c34ec3ce1c81',
#              action_type='SET_HEAT',
#              status='success',
#              result={},
#              error=None)

fan_on_request = seam.thermostats.set_fan_mode(
  device = "054765c8-a2fc-4599-b486-14c19f462c45",
  fan_mode = "on"
)
pprint(fan_on_request)

# ActionAttempt(action_attempt_id='9c9b584b-c645-4ce0-a9c2-79b6f1db2396',
#              action_type='SET_FAN_MODE',
#              status='success',
#              result={},
#              error=None)

Next Steps

Now that you have completed this guide, you can try to connect a real Google Nest device. To do so, make sure to switch to a non-sandbox workspace and API key because you cannot connect real devices to sandbox workspaces.

If you have any questions or want to report an issue, email us at support@seam.co.

Last updated

Logo

© Seam Labs, Inc. All rights reserved.