Yonomi Blog

How to Integrate an ecobee Smart Thermostat

Written by Wilson Hughes | Jun 21, 2022 5:45:49 AM

As important as smart locks have been to vacation rental, smart thermostats may play an even more important role in helping hosts manage the operational expenses of a short-term rental business.

Depending on where the property is located in the world, heating or cooling unoccupied units can result in significant costs and cut substantially into rental revenue. In many cases, hosts are left to rely on their cleaning service crews to help manage temperatures in-between reservations. This is unreliable and doesn't account for the scenarios where pre-cooling/heating a unit just before a guest arrives would deliver the best guest experience.

If you run a property management company or short-term rental business, switching out your old thermostat for an ecobee smart thermostat can yield significant benefits to your bottom line... but only if you can take advantage of its most useful features.  

If you are a developer, keep reading. If you prefer to talk to someone about your business needs, click the button below or follow this link to schedule a half-hour discovery call.

To take full advantage of the benefits of smart thermostats, you’ll need to be able to integrate with them.  Yonomi makes this process easy by providing a GraphQL-based API to perform the most important smart thermostat functions with ecobee smart thermostats.  Using Yonomi's API you can automatically manage ecobee smart thermostat settings for all your rental units, including: 

  • changing thermostat mode to off when guests check out 
  • pre-climatizing a unit just before guest arrival
  • monitoring thermostat setpoint temperature throughout a reservation


How to Integrate an ecobee Smart Thermostat

  1. Create a Yonomi Developer Portal Account

    To get started, navigate to the Yonomi Developer Playground and sign up for a free developer account. The playground provides a web-based development environment for interacting with the Yonomi Platform. Click on Sign-up at the bottom of the login screen if you don't have an account.



  2. Query for the ecobee Integration ID in Yonomi Platform

    Next, we’ll look at available integrations. Yonomi establishes authorization to supported devices through an Integration object.

    An Integration represents a connection to the 3rd-party cloud which provides APIs to interact with the devices that 3rd party sells and supports. As an example, Yonomi supports integration to the ecobee cloud, and ecobee uses their cloud to expose APIs used to interact with the thermostats they sell. The Integration object allows developers to create applications that let end-users programmatically establish an authorization link between their application user and their ecobee  account. 

    To query available Integrations, remove or rename the existing query in the left-side editor window and then paste the following query in the editor below the health query:
query getAllIntegrations {
integrations {
edges {
  node {
   id
   displayName
  }
}
}
}

Click the Play button and select getAllIntegrations from the dropdown that appears under the button to execute the GraphQL query.  The response is a list of details for all available integrations on the Yonomi Platform, including the ecobee integrationID which we'll use in the next step.

If you received an error, please be sure you either deleted or renamed the existing anonymous query.   

  1. Create an ecobee Account Linking URL

Once you have the ecobee integrationID you can use it to obtain an account linking URL for a ecobee account and authorize the ecobee thermostats associated with that account for API access. Identify the Integration ID for the ecobee Integration object from the results of the previous call – you’ll populate this value as a query variable.

mutation generateAccountLinkingUrl ($integrationId: ID!) {
  generateAccountLinkingUrl(integrationId: $integrationId) {
url
    expiresAt
    integration {
      id
      displayName
    }
  }
}

Notice this mutation uses a query variable called integrationId that we’ll need to populate. Scroll down to the Query Variables area at the bottom of the Editor window area. You may need to grab and drag the Query variable pane up to access it.  Once accessible, paste the following:

{
"integrationId": "replaceWithEcobeeIntegrationID"
}

Copy the integrationID of the ecobee Integration object from the previous call and paste it as the value of the integrationId variable, replacing the existing value (replaceWithEcobeeIntegrationID):

Click the Play button and select the generateAccountLinkingUrl mutation to run that call. The response will be a payload that includes a long URL – this is the Account Linking URL for an ecobee account.

  1. Authorize the ecobee Account

    Next, we’ll authorize a ecobee account. Copy the URL, paste it into a new browser tab and run it.

    The token used in this request has an expiration timeframe of only 120 seconds, so you’ll need to work fast at this step, copying the URL and pasting it into a browser within 2 minutes.

    You should see the browser load a page with instructions to log in to your ecobee account.  Also notice here that the browser URL shows you have been redirected to a ecobee site, not a Yonomi site. This is the redirect mentioned in step 3 of the flow above.



    Enter your ecobee account details and click the Sign In button to log in. Upon successful login ecobee will present a screen confirming your request to authorize Yonomi access to devices.

    Upon clicking the "Authorize" button, you'll be redirected back to a Yonomi URL, where you’ll be greeted with a Success message; if you’ve established a Callback URL with Yonomi then instead you’ll be redirected to the callback URL so your application can seamlessly pick up from Yonomi in the process.



    At this point, a LinkedAccount and one or more Device objects have been added to the user’s Yonomi Platform account.

  2. View linked devices

    Once the Linked Account was authorized and added, any thermostats (or leak sensors) associated with that account were also added. To see available devices, paste and run the following query:

query getMyDevices {
  me {
    devices {
      edges {
        node {
          id
          displayName
          productInformation {
            description
            manufacturer
            model
            serialNumber
          }
        }
      }
    }
  }
}

Notice the Device ID (id) in the response – we’ll need to use this for the next step. You’ll find the device ID as the first id variable under each node object in the response (per the GraphQL query above).

  1. Run Device Actions – Change thermostat mode

    We’re now ready to control our thermostat. We’ll start by changing the mode. Be sure your thermostat is in Off mode or at least in a different mode than you intend to set it.

    Paste the following mutation in the editor:

mutation makeSetThermostatModeRequest ($deviceId: ID!) {
actionThermostatSettingSetThermostatMode (deviceId: $deviceId mode: OFF) {
actionId
device {
traits {
name instance
... on ThermostatSettingDeviceTrait {
properties {
availableThermostatModes
availableFanModes
}
state {
mode {
reported { value sampledAt createdAt }
desired { value delta updatedAt }
}
}
}
}
}
}
}
 

Next, copy the thermostat's DeviceID from the getMyDevices query response in the previous step. Open the Query Variables pop-up window and add the following variable, replacing replaceWithDeviceID with your copied DeviceID:

"deviceId": "replaceWithDeviceID"

Be sure to include commas between variable definitions.

Click the play button and select the makeModeChangeRequest request from the list to execute it.  Your thermostat should change from current mode to Off mode.  To change the thermostat to Cool or Heat mode, simply change the mode variable of the makeModeChangeRequest  mutation from OFF to COOL or HEAT.

Congratulations - you've just controlled your ecobee smart thermostat via API using Yonomi Platform - and hopefully, it was easier than you expected. :)

Yonomi’s API provides support not only for ecobee Smart Thermostats  but for many other smart home devices, including Honeywell thermostats, Schlage Locks, TP-Link and Philips lights, and much more.  

To dig into the API to learn how to obtain thermostat state and change temperature browse to our developer site at https://developers.yonomi.com.

Want to speak to a human? Follow this link to schedule a half-hour strategy session. We'd like to understand your business needs and see how we can support you.