Previous Example Next Example

Example 8: Setting the mode of your thermostat

Note on token authentication:

If you have completed the authentication process from Example 1, your access token will be pre-populated in all requests throughout every example.

To specify a different access token, please paste it in the form below and press 'Update'. Alternatively, you can go back to the first example here to re-authenticate. Doing either will save your access token for all future examples.

Access Token:


To set the mode of the thermostat, we have to change the hvacMode of the Settings object. We can do this with a simple Post Update Thermostats request.

Let us prepare the json.txt file with the following JSON object, which will change the matched thermostats to off mode.

{
  "selection": {
    "selectionType":"registered",
    "selectionMatch":""
  },
  "thermostat": {
    "settings":{
      "hvacMode":"off"
    }
  }
}							
							

We will then use cURL to perform the POST request.

curl -s --request POST --data-urlencode @json.txt -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: Bearer ACCESS_TOKEN" "https://api.ecobee.com/1/thermostat?format=json"							
							

If the post is successful, you should see this.

{
  "status": {
    "code": 0,
    "message": ""
  }
}							
							

Now let us verify the changed settings.

curl -s -H 'Content-Type: text/json' -H 'Authorization: Bearer ACCESS_TOKEN' 'https://api.ecobee.com/1/thermostat?format=json&body=\{"selection":\{"selectionType":"registered","selectionMatch":"","includeSettings":true\}\}'
							
{
  "page": {
    "page": 1,
    "totalPages": 1,
    "pageSize": 1,
    "total": 1
  },
  "thermostatList": [
    {
      "identifier": "318324666667",
      "name": "Main Floor",
      "thermostatRev": "150213180856",
      "isRegistered": true,
      "modelNumber": "athenaSmart",
      "lastModified": "2015-02-13 18:08:56",
      "thermostatTime": "2015-02-13 13:10:47",
      "utcTime": "2015-02-13 18:10:47",
      "settings": {
        "hvacMode": "off",
        "lastServiceDate": "2014-01-03",
        ...snipped...
        "groupRef": "",
        "groupName": "",
        "groupSetting": 0
      }
    }
  ],
  "status": {
    "code": 0,
    "message": ""
  }
}							
							

Let us change it back to heat mode. The content of the json.txt file should be changed to:

{
  "selection": {
    "selectionType":"registered",
    "selectionMatch":""
  },
  "thermostat": {
    "settings":{
      "hvacMode":"heat"
    }
  }
}							
							

We will then use cURL to perform the POST request.

curl -s --request POST --data-urlencode @json.txt -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: Bearer ACCESS_TOKEN" "https://api.ecobee.com/1/thermostat?format=json"							
							

If the post is successful, you should see this.

{
  "status": {
    "code": 0,
    "message": ""
  }
}							
							

Reissue a request for obtaining the settings to see if the mode is back to heat.

curl -s -H 'Content-Type: text/json' -H 'Authorization: Bearer ACCESS_TOKEN' 'https://api.ecobee.com/1/thermostat?format=json&body=\{"selection":\{"selectionType":"registered","selectionMatch":"","includeSettings":true\}\}'
							
{
  "page": {
    "page": 1,
    "totalPages": 1,
    "pageSize": 1,
    "total": 1
  },
  "thermostatList": [
    {
      "identifier": "318324666667",
      "name": "Main Floor",
      "thermostatRev": "150213181314",
      "isRegistered": true,
      "modelNumber": "athenaSmart",
      "lastModified": "2015-02-13 18:13:14",
      "thermostatTime": "2015-02-13 13:13:26",
      "utcTime": "2015-02-13 18:13:26",
      "settings": {
        "hvacMode": "heat",
        "lastServiceDate": "2014-01-03",
        ...snipped...
        "groupRef": "",
        "groupName": "",
        "groupSetting": 0
      }
    }
  ],
  "status": {
    "code": 0,
    "message": ""
  }
}							
							

In the next example, we will learn how to create a vacation event.

Previous Example Next Example