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.
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.
2. Link Google Nest Account with Seam
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 seam import Seamseam =Seam()webview = seam.connect_webviews.create(accepted_providers=["google_nest"])assert webview.login_successful isFalse# Send the Connect Webview URL to your user.print(webview.url)
import { Seam } from'seam'constseam=newSeam()constconnectWebview=awaitseam.connectWebviews.create({ accepted_providers: ["google_nest"],})console.log(connectWebview.login_successful) // false// Send the Connect Webview URL to your user.console.log(connectWebview.url)
useSeam\SeamClient;$seam =newSeamClient("YOUR_API_KEY");$webview = $seam->connect_webviews->create( accepted_providers: ["google_nest"]);# Send this Connect Webview URL to your user.echojson_encode($webview)
ConnectWebview createdConnectWebview =seam.connectWebviews().create(ConnectWebviewsCreateRequest.builder().acceptedProviders(List.of(AcceptedProvider.NEST)).build());System.out.println(createdConnectWebview.getLoginSuccessful()); // false// Send the Connect Webview URL to your user.System.out.println(createdConnectWebview.getUrl());
connectWebview, err := client.ConnectWebviews.Create( context.Background(),&api.ConnectWebviewsCreateRequest{ AcceptedProviders: []api.AcceptedProvider{ api.AcceptedProviderNest, }, },)if err !=nil {return err}fmt.Println(connectWebview.LoginSuccessful) // false# Send the Connect Webview URL to your user.fmt.Println(connectWebview.Url)returnnil
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:
var deviceId ="054765c8-a2fc-4599-b486-14c19f462c45";seam.thermostats().heat(ThermostatsHeatRequest.builder().deviceId(deviceId).heatingSetPointCelsius(20.0).build());Device thermostat =seam.thermostats().get(ThermostatsGetRequest.builder().deviceId(deviceId).build());System.out.println("Thermostat ID: "+thermostat.getDeviceId());System.out.println("Mode: "+thermostat.getProperties().getCurrentClimateSetting().get().getHvacModeSetting());System.out.println("Heating set point (Celsius): "+thermostat.getProperties().getCurrentClimateSetting().get().getHeatingSetPointCelsius());// Thermostat ID: 054765c8-a2fc-4599-b486-14c19f462c45// Mode: Optional[heat]// Heating set point (Celsius): Optional[20.0]
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.