Example 3: Obtaining the thermostat mode (heat / cool / off)
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.
The current mode of the thermostat can be determined from the hvacMode property of the Settings object. We will use the GET Thermostat API call.
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\}\}'
The settings JSON is quite large from the response, so we will just show the relevant parts here.
{ "page": { "page": 1, "totalPages": 1, "pageSize": 1, "total": 1 }, "thermostatList": [ { "identifier": "318364662718", "name": "Main Floor", ...snipped... "utcTime": "2015-02-12 15:25:17", "settings": { "hvacMode": "heat", "lastServiceDate": "2014-01-03", "serviceRemindMe": false, "monthsBetweenService": 6, ...snipped... "ventilatorFreeCooling": true, "dehumidifyWhenHeating": false, "ventilatorDehumidify": true, "groupRef": "", "groupName": "", "groupSetting": 0 } } ], "status": { "code": 0, "message": "" } }
Note that the hvacMode property is the first property of the Settings object within the above JSON.
In the above example, we show that the thermostat is in heat mode. Other possible values are:
- auto
- auxHeatOnly
- cool
- heat
- off
Now let us see how we can determine which equipment is currently running with our next example.